MATLAB: Error using * in a simple matlab program

*dimensionserrormultiplication

>> format short e
C=1;
O=0;
y=3;
m=1;
w=50;
t=0:1:10;
f=C.*exp(-(y.*t)/(2.*m))*cos(w.*t+O);
disp([t,f])
Error using *
Inner matrix dimensions must agree.

Best Answer

C=1;
O=0;
y=3;
m=1;
w=50;
t=0:1:10;
f=C.*exp(-(y.*t)./(2.*m)).*cos(w.*t+O);
Be careful that you should be doing element-wise multiplication while multipyling the exp term with cos term.