Array indices must be positive integers or logical values.
Show older comments
it says the error is on line 13
s(t)=[0.1553567*(t^6)-2.0416*(t^5)+9.1837*(t^4)-14.829*(t^3)...
-1.3703*(t^2)+32.821*(t)-1.3155];
and I'm trying to make a loop to plot a graph for this https://screenshotscdn.firefoxusercontent.com/images/1a144e46-fb07-4a6c-9757-1788e9a3adfe.png so if you notice any errors please let me know
2 Comments
Image Analyst
on 27 Nov 2018
Original question, so it will be here when he tries to edit it away:
It says the error is on line 13
s(t)=[0.1553567*(t^6)-2.0416*(t^5)+9.1837*(t^4)-14.829*(t^3)...
-1.3703*(t^2)+32.821*(t)-1.3155];
and I'm trying to make a loop to plot a graph for this My Picture so if you notice any errors please let me know.
Walter Roberson
on 27 Nov 2018
The screenshot URL is no longer valid.
Answers (1)
John D'Errico
on 4 Nov 2018
Edited: John D'Errico
on 4 Nov 2018
What is t? You may think you are creating a function by doing this:
s(t)=[0.1553567*(t^6)-2.0416*(t^5)+9.1837*(t^4)-14.829*(t^3)...
-1.3703*(t^2)+32.821*(t)-1.3155];
But that is not how MATLAB syntax works.
In fact, MATLAB does not understand what you want. Instead, it think that s is a variable, and t is an index. is t an integer vector or array? (Clearly not, else you would not have gotten that error message.)
So, MATLAB tries to assign the element s(t), but if t is not something can be used to index, then MATLAB gets confused.
2 Comments
Walter Roberson
on 4 Nov 2018
Assign to s(t+1)
I recommend that you experiment with 5>=t<15.4 as it seems unlikely to be what you want at that point.
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!