Text Option does not work in a Figure (Matlab 2017a)

I am using Matlab 2017a and somehow can't be able to use the "text" option in Matlab Figure. I am getting two error messages "Index exceeds matrix dimensions" and "Subscript indices must either be real positive integers or logicals". Here are some explames:
>> plot(1:10)
text(2,8,'A Simple Plot','Color','red','FontSize',14)
Index exceeds matrix dimensions.
>> x = linspace(-5,5);
y = x.^3-12*x;
plot(x,y)
xt = [-2 2];
yt = [16 -16];
str = 'dy/dx = 0';
text(xt,yt,str)
Subscript indices must either be real positive integers or logicals.
These simple codes were working when I used Matlab 2015. Could you please help me to figure out why I am getting these error messages?
Thanks,
Paul

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 29 Okt. 2018

0 Stimmen

You have accidentally assigned to a variable named text.

1 Kommentar

Pallab
Pallab am 29 Okt. 2018
Thank you so much Walter!!! I spent hours on those error messages and had no clue what was going on. You saved my day and I cannot tell you how grateful I am for your help.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by