how to rectify this

8 次查看(过去 30 天)
sudhir sa
sudhir sa 2022-5-5
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 个评论
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
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.

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by