Why am I getting "Array indices must be positive or integers values"?

1 回表示 (過去 30 日間)
Edgar Soriano
Edgar Soriano 2020 年 9 月 28 日
コメント済み: Star Strider 2020 年 9 月 29 日
This is a sine function, which should give me positive and negative values.
syms t
t = 0:0.02:2;
om = 10;
% Steady State Response
up(t)=(100/(400-om^2))*sin(om*t);
plot(t,up(t))
xlabel('Time (sec)')
ylabel('Displacement (in)')
title('Displacement vs Time Response')
Array indices must be positive integers or logical values.
Error in HW5plot (line 6)
up(t)=(100/(400-om^2))*sin(om*t);

採用された回答

Star Strider
Star Strider 2020 年 9 月 28 日
Rhe reason is that ‘up(t)’ was being interpreted as an indexing operation rather than a function call, and ‘t’ are not all positive integers. The plot call was also inappropriate.
Try this:
syms t
om = 10;
% Steady State Response
up(t)=(100/(400-om^2))*sin(om*t);
figure
fplot(up, [0 2])
xlabel('Time (sec)')
ylabel('Displacement (in)')
title('Displacement vs Time Response')
.
  2 件のコメント
Edgar Soriano
Edgar Soriano 2020 年 9 月 29 日
Thank you! This solved the issue.
Star Strider
Star Strider 2020 年 9 月 29 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumber Theory についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by