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);
0 个评论
采纳的回答
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 Center 和 File Exchange 中查找有关 Number Theory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!