Dear sir
plot command not functioning for the simple cide
clc
clear all
t=0:0.1:2;
plot(t,sin(t))
showing errors as
Unrecognized function or variable
'currentFigure'.
Error in matlab.graphics.internal.newplotwrapper
(line 14)
if isempty(currentFigure)
Error in Untitled3 (line 4)
plot(t,sin(t))
pls suggest

댓글 수: 6

What version you are using?
clc
clear all
t=0:0.1:2;
figure(1)
plot(t,sin(t))
sudhir sa
sudhir sa 2022년 5월 5일
R2020b
i run a code which takes several minutes , so in middle i stopped. after that i am getting such type of error for the code which i allready get results (plot)
KSSV
KSSV 2022년 5월 5일
The code which you gave should not take much time. Is the attched code,you gave plotting?
sudhir sa
sudhir sa 2022년 5월 5일
No sir, another code. the code attached here is only for testifying
KSSV
KSSV 2022년 5월 5일
Then you should show us the code, which you gives you error.
sudhir sa
sudhir sa 2022년 5월 5일
not for a single code but for all the code for which i already got the plot , now showing similar error which i hav mentioned above. the same code is running and also giving plot on online matlab platform.

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

답변 (1개)

Animesh Gupta
Animesh Gupta 2022년 5월 19일

0 개 추천

Hello,
It is my understanding that plot function is not working in your case, and you are receiving the mentioned error.
To fix the error you can insert the plotting code inside if block as:
clc
clear all
figure;
t=0:0.1:2;
g = groot;
fig = get(groot, 'CurrentFigure');
if ~isempty(fig) % true if there are no open graphics objects, false otherwise
% code to plot
plot(t,sin(t));
end
You can also refer the following link for more details -
I hope it helps.

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

질문:

2022년 5월 5일

답변:

2022년 5월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by