Possible matlab bug with text() function?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Azhar Ali
am 18 Sep. 2019
Kommentiert: Steven Lord
am 18 Sep. 2019
I'm having issues with the text function. I am copying your example from the documentation, and I get the following error:
"Subscript indices must either be real positive integers or logicals."
Here is the example:
x = 0:pi/20:2*pi;
y = sin(x);
plot(x,y)
text(pi,0,'\leftarrow sin(\pi)')
I am using Matlab 2013a. Very simple example, not sure why I can't replicate the documentation example. Thank in advance!
2 Kommentare
Akzeptierte Antwort
madhan ravi
am 18 Sep. 2019
Bearbeitet: madhan ravi
am 18 Sep. 2019
When you name variable as the same name as the function this happens.
clear text plot sin % not sure which function you’re shadowing , but it definitely is a reason
0 Kommentare
Weitere Antworten (1)
Azhar Ali
am 18 Sep. 2019
1 Kommentar
Steven Lord
am 18 Sep. 2019
If this recurs, set an error breakpoint and run your code. When you receive the error, check if you are in a function named text.m (which would be shadowing the built-in text function.) If you are not, post the full text of the error message (all the text displayed in red, not just the "Subscript indices must either be real positive integers or logicals." part) and it may provide the information needed to determine the cause.
Siehe auch
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!