Matlab chokes on 'end' operator

I am trying to run a script and cannot go beyond the line that plots
% Plot the relative Position Error for an entire week after the epoch time
% of the latest ephemeris
TIME = VAL(10,end-1):60/86400:VAL(10,end)-60/86400;
P1=figure;plot(TIME(end-10079:end),POSERR);
the error I'm getting is
  • _ *Subscript indices must either be real positive integers or logicals* _ *
all variables have been defined

1 件のコメント

James Tursa
James Tursa 2014 年 7 月 16 日
What are the dimensions of the variables involved? Have you used the debugger to pause execution at that line to verify the variable dimensions?

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

 採用された回答

Image Analyst
Image Analyst 2014 年 7 月 16 日

0 投票

Looks to me like it should be okay. Try putting parentheses around "end-1" and "end-10079" and see if that fixes it. If it doesn't then set
lastTimeIndex = length(TIME);
lastValIndex = size(VAL, 2);
and then use lastTimeIndex and lastValIndex instead of end and see if that works.
Do you want parentheses around "VAL(10,end)-60/86400" or not. That's another thing to check.

2 件のコメント

Paul
Paul 2014 年 7 月 16 日
Thank you, very much the assignment worked. I don't know why the 'end' did not, but now, after I used lastTimeIndex. it all works
Image Analyst
Image Analyst 2014 年 7 月 17 日
Glad it worked. Please go ahead and mark the answer as "Accepted" then.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

質問済み:

2014 年 7 月 16 日

コメント済み:

2014 年 7 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by