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

1 次查看(过去 30 天)
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')
.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Number Theory 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by