Possible matlab bug with text() function?
이전 댓글 표시
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
Kevin Phung
2019년 9월 18일
where is it throwing the error? It runs for me
Azhar Ali
2019년 9월 18일
채택된 답변
추가 답변 (2개)
Azhar Ali
2019년 9월 18일
0 개 추천
댓글 수: 1
Steven Lord
2019년 9월 18일
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.
Lola Gadea
2024년 6월 9일
0 개 추천
I have the same problem with the 2023a version:
x = 0:pi/20:2*pi;
y = sin(x);
plot(x,y)
text(pi,0,'\leftarrow sin(\pi)')
Index in position 1 is invalid. Array indices must be positive integers or logical values.
Error in example_labels5 (line 4)
text(pi,0,'\leftarrow sin(\pi)')
댓글 수: 1
What does this command show?
which -all text
I'm betting it will show something that looks like the following instead of the text above (note the first line.)
text = 42;
which -all text
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!