Index exceeds matrix dimensions

I have a file that plots results from a simulation. Ive been using it for a long time and now it has started giving me this problem:
Index exceeds matrix dimensions.
Error in Plot_Results (line 210)
title('Velocity of cycle')
The first time I run the file it works fine. But if I run it again without changing anything (and there is nothing to clear any variables in the code) it gives me that error. If I comment out every title, xlabel, and ylabel line then itll work fine and will plot the several plots I have in the file but with no titles or anything. This just started happening and I cant figure out why. The code was working just fine before this randomly started happening.
thanks

 採用された回答

Will
Will 2012 年 2 月 20 日

30 投票

Alright I figured it out. For some reason it wasnt rewriting the title variable from an old run so i just added "clear title xlabel ylabel" and that seems to have fixed it.

11 件のコメント

Kiniena
Kiniena 2014 年 12 月 18 日
Thanks
Marlon Saveri Silva
Marlon Saveri Silva 2015 年 8 月 14 日
Thanks o/
Ivailo
Ivailo 2016 年 1 月 19 日
Thanks
Ian Adler
Ian Adler 2016 年 6 月 23 日
Thank you so much
shir shalom
shir shalom 2017 年 2 月 11 日
Thanks!
Thomas Gurnett
Thomas Gurnett 2017 年 3 月 4 日
Cheers
Rania Ezzo
Rania Ezzo 2017 年 4 月 22 日
Thank you. This was helpful.
Edward McCarthy
Edward McCarthy 2017 年 10 月 2 日
This worked for me
Jennifer Scoular
Jennifer Scoular 2018 年 6 月 21 日
Was getting mega frustrated and this worked thanks!
Bahare Samadi
Bahare Samadi 2018 年 11 月 30 日
Thanks. It was very helpful.
Mariana Rodrigues
Mariana Rodrigues 2019 年 1 月 17 日
Thank you!!

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

その他の回答 (3 件)

Qiu
Qiu 2018 年 2 月 23 日

2 投票

I just found that I accidentally used the name "title" for a string, which confused Matlab. Try use another name.
Jacob Wicks
Jacob Wicks 2019 年 1 月 10 日

2 投票

I had made xlabel and ylabel a variable which gave me the error about index exceeds array.
xlabel = ('time')
ylabel = ('something')
all I had to do was clear these variables
>>clear xlabel
>>clear ylabel
and use the proper syntax
xlabel('time')
ylabel('something')
Haseeb Ahmed Janjua
Haseeb Ahmed Janjua 2017 年 9 月 27 日

0 投票

whenever I create this function in editor
function r = Ymaxfinal(p,q)
r = ((-1000*p*q)/(27*(30*10^6)*0.163*(p+q)))*(p+(2*q))*((3*p(p+(2*q)))^0.5);
end
but when I call it in command window like Ymaxfinal(9,8)
it gives the error of Index exceeds matrix dimensions. plz help me

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

タグ

質問済み:

2012 年 2 月 20 日

コメント済み:

2019 年 1 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by