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

4 ビュー (過去 30 日間)
Zachary Heupel
Zachary Heupel 2019 年 2 月 17 日
コメント済み: Stephen23 2019 年 2 月 18 日
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.

回答 (1 件)

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

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by