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

 Risposta accettata

Will
Will il 20 Feb 2012

30 voti

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 Commenti

Kiniena
Kiniena il 18 Dic 2014
Thanks
Thanks o/
Ivailo
Ivailo il 19 Gen 2016
Thanks
Ian Adler
Ian Adler il 23 Giu 2016
Thank you so much
Thanks!
Cheers
Rania Ezzo
Rania Ezzo il 22 Apr 2017
Thank you. This was helpful.
This worked for me
Was getting mega frustrated and this worked thanks!
Thanks. It was very helpful.
Thank you!!

Accedi per commentare.

Più risposte (3)

Qiu
Qiu il 23 Feb 2018

2 voti

I just found that I accidentally used the name "title" for a string, which confused Matlab. Try use another name.
Jacob Wicks
Jacob Wicks il 10 Gen 2019
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 il 27 Set 2017

0 voti

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

Categorie

Scopri di più su Mathematics in Centro assistenza e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by