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

4 views (last 30 days)
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.

Answers (1)

Star Strider
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.

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!