MATLAB Answers

0

Why am I not getting an array of answers from this operation?

Asked by Zachary Heupel on 17 Feb 2019
Latest activity Commented on by Stephen Cobeldick on 18 Feb 2019
t=linspace(0,3.5,1000);
u=4*exp^(-0.45*t.)*sin(4*t. + 0.5);
I want u to be an array that is the same size as t, but whenever i try to run this matlab says I have a parse error at ')' referring to the first closing parenthesis. I also tried making u an anonymous function of t but I could not get that to work either.

  0 Comments

Sign in to comment.

Products


Release

R2018b

1 Answer

Answer by Star Strider
on 17 Feb 2019

Because you coded it with incorrect syntax.
Try this:
t=linspace(0,3.5,1000);
u=4*exp(-0.45*t).*sin(4*t + 0.5);
figure
plot(t, u)
grid
Note the element-wise multiplication (using .* rather than *), and other improvements.

  1 Comment

Sign in to comment.