simple problem for experienced user
simple problem for experienced user
(OP)
Hi all,
For some reason I can't seem to be able to use this function:
You can see the associated error message, can someone help me please ?
By the way,
Thanks,
-R
For some reason I can't seem to be able to use this function:
CODE
>> 0.206*exp((-3.747*t))*sin(15.36*t)
??? Error using ==> *
Inner matrix dimensions must agree.
??? Error using ==> *
Inner matrix dimensions must agree.
By the way,
CODE
t=0:0.01:10;
-R





RE: simple problem for experienced user
CODE
0.206*exp((-3.747*t)).*sin(15.36*t)
RE: simple problem for experienced user
I knew it was simple ... I never was familiar with the ".*" operator.
Thanks for the quick reply
-R
RE: simple problem for experienced user
what your first line does is multiply 2 line vectors using the matrix multiplication.
As what you want is to do element-by-element multiplication, you have to use the ".*" operator where necessary:
CODE
quicker than me, jisb
RE: simple problem for experienced user
So if I am getting this correctly, since I want to plot this function, I need several values therefor I need to multiply them on an element by element basis ? Is this correct ?
RE: simple problem for experienced user
In this case, length(t) is 1001. You originally tried to multiply (examining the dimension only) (1x1001)*(1x1001). If you look at the inner two dimensions, i.e., 1001)*(1, they are of different sizes. What you were really tring to do is to multiply the magnitudes of the two terms evaluated at each individual point in vector t (i.e., perform element by element multiplication, as tompouce indicated), not multiply the two vectors. This will result in an answer that is 1x1001 in dimension, which can then be plotted against t, since to plot, the lengths of the two vectors must also be equal.
xnuke
Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
RE: simple problem for experienced user
as you're only working on the same function calculated at different times, you need to do an element by element multiplication (in opposition to on a single calculation using matrix arguments)
Tom