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

 Respuesta aceptada

Walter Roberson
Walter Roberson el 29 de Oct. de 2018

0 votos

You have accidentally assigned to a variable named text.

1 comentario

Pallab
Pallab el 29 de Oct. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Preguntada:

el 29 de Oct. de 2018

Editada:

el 29 de Oct. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by