Possible matlab bug with text() function?

조회 수: 1 (최근 30일)
Azhar Ali
Azhar Ali 2019년 9월 18일
댓글: Steven Lord 2019년 9월 18일
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
Kevin Phung 2019년 9월 18일
where is it throwing the error? It runs for me
Azhar Ali
Azhar Ali 2019년 9월 18일
Error is thrown for text function despite no other variables in workspace. Reboot of computer and Matlab resolved issue.

댓글을 달려면 로그인하십시오.

채택된 답변

madhan ravi
madhan ravi 2019년 9월 18일
편집: madhan ravi 2019년 9월 18일
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

추가 답변 (1개)

Azhar Ali
Azhar Ali 2019년 9월 18일
I had no variables in my workplace (clear; clc; close all) and I still had the error. I rebooted computer and Matlab and it resolved the issue. Weird. Still don't know why I got the error, but problem is fixed. Thanks all.
  댓글 수: 1
Steven Lord
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2013a

Community Treasure Hunt

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

Start Hunting!

Translated by