Error:Subscript indices must either be real positive integers or logicals.

Hi,
I get this error ,
Subscript indices must either be real positive integers or logicals. The line with this error is,
simout_diff=(simout_ps(t_plot,:,1))-(full_vehicle_data_cw(t_plot,:,1));
Please help me in resolving this error and what is meant by subscript indices?

 Accepted Answer

Matlab is telling you that 't_plot' is neither an integer greater than zero nor a logical variable. Since it is interpreted as an index to both the 'simout_ps' and 'full_vehicle_data_cw' arrays, this violates one of matlab's rules. In case you meant these to be functions rather than arrays, then for some reason matlab is not recognizing them as such.

5 Comments

So in that case,could you please tell what function can be used possibly in place of t_plot. How will I represent the time plot?
t_plot is just a variable!. You have to post the whole code to find out what you have put inside t_plot!
V=20;
t_sim=30;
sample_distance=0.2;
ts=sample_distance/V;
collect_ts=ts*1;
t_plot=(0:collect_ts:t_sim);
Well there's your problem. See where you set the first element of t_plot to zero? Can't do that and have t_plot as an index into an array such as full_vehicle_data_cw.
Thanks for you reply. But could you please tell if I need to define the time vector whose simulation length is 30s, how will I do that.

Sign in to comment.

More Answers (0)

Categories

Tags

Asked:

on 30 Jan 2014

Commented:

on 30 Jan 2014

Community Treasure Hunt

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

Start Hunting!