Why am I not getting an array of answers from this operation?
4 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Star Strider
2019 年 2 月 17 日
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 件のコメント
Stephen23
2019 年 2 月 18 日
Read more here:
Learning the difference is critical to using MATLAB.
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!