# Help in MATLAB, plotting a signal

• MATLAB
I'm pretty new in MATLAB, and I can't seem to get it to display a signal. I have the following:

t=1:1:100;
s= 2*sin(2*pi*.05*t)*5*sin(2*pi*2*t)+.75*randn;
plot(t,s)

But i keeps giving me the following error:

??? Error using ==> mtimes
Inner matrix dimensions must agree.

Error in ==> signal at 5
s= 2*sin(2*pi*.05*t)*5*sin(2*pi*2*t)+.75*randn;

Does anyone have any suggestions?

one of the things about MATLAB is that the "*" symbol means matrix multiplication, but has been allowed to be used when either the left or right operand (or both) are scalers (which, in MATLAB is a 1x1 matrix, but they recognize that and assign meaning to a multiplication of that as a scaler against any matrix). but what you can't do is multiply two matrices together (bigger than the 1x1, which is dually interpreted as a scaler), unless the number of columns of the left operand is equal to the number of rows of the right. to do element-by-element multiplication of two identically sized and shaped arrays (i won't call them "matrices" here), you use the ".*" operator. sometimes you'll also need to use the ".^" operator, too, because the normal power operator "^" also has matrix meaning when one of the operands are matrices.

oh, i forgot to correct the expression:

s= (2*sin(2*pi*.05*t)) .* (5*sin(2*pi*2*t)) +.75*randn(size(t));

i think that will work.

Last edited:
That worked perfectly. Thanks so much for the help and quick reply :-)