Error encountered when attempting to use Text()
Show older comments
Hi, I'm relatively new to Matlab. I've been trying to annotate some specific points in my graph but keep encountering this error: "Subscript indices must either be real positive integers or logicals.". This error appears even when I used the example code (see below). I noticed that if I start my command window fresh, the example code works fine, but as soon as I load my data, the error appears again both when I plot my own data and when I use the example code. Any idea as to why this is the case? Thanks
x = 0:pi/20:2*pi;
y = sin(x);
figure % new figure window
plot(x,y)
text(pi,0,' \leftarrow sin(\pi)')
Subscript indices must either be real positive integers or logicals.
Accepted Answer
More Answers (1)
Image Analyst
on 25 Jan 2015
0 votes
It works fine for me - no errors. And I can run it over and over again with no errors. Perhaps you used Text() (like you said in your subject line) instead of text(). MATLAB is case sensitive.
Come back with the complete code if the FAQ does not answer your question: http://matlab.wikia.com/wiki/FAQ#How_do_I_fix_the_error_.22Subscript_indices_must_either_be_real_positive_integers_or_logicals..22.3F
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!