MATLAB Practice Room

For the PSUC end-sem, Thu 26 Nov. Read the short idea, look at the Command Window example, then answer. Each answer is checked as you go and shows what MATLAB would print. Your progress stays on this phone.

0 of 0 right
Exam trap list

C habits that break in MATLAB

In C
In MATLAB
Arrays start at index 0
Arrays start at index 1; v(0) is an error
a[2]
a(2), round brackets
{ } around blocks
Every if, for, while, function closes with end
!= for not equal
~=
; ends every statement
; only hides the output; without it MATLAB prints the result
Declare int x; first
No declarations; x = 5 creates x
printf
fprintf (same format codes) or disp
for(i=1;i<=n;i++)
for i = 1:n ... end
Comment with //
Comment with %
* multiplies numbers
* is matrix multiplication; .* multiplies element by element