Why am I not getting an array of answers from this operation?
4 views (last 30 days)
Show older comments
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
Answers (1)
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
Stephen23
on 18 Feb 2019
Read more here:
Learning the difference is critical to using MATLAB.
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!