Error using plot Undefined function or variable 'newplot'.

Hi,
I am using Matlab via Citrix. I am getting the following error while using plot function.
Error using plot in line 30
Undefined function or variable 'newplot'.
% Jake's Method
% close all;
clear all;
N=30;
M=0.5*(N/2-1);
wn(M)=0;
beta(M)=0;
ritemp(M,2001)=0;
rqtemp(M,2001)=0;
rialpha(1,2001)=0;
fm=[1 10 100];
Wm=2*pi*fm;
for i=1:3
for n=1:1:M
for t=0:0.001:2
Wn(n)=Wm(i)*cos(2*pi*n/N);
beta(n)=pi*n/M;
ritemp(n,round(1000*t+1))=2*cos(beta(n))*cos(Wn(n)*t);
rqtemp(n,round(1000*t+1))=2*sin(beta(n))*cos(Wn(n)*t);
rialpha(1,round(1000*t+1))=2*cos(Wm(i)*t)/sqrt(2);
end
end
ri=sum(ritemp)+rialpha;
rq=sum(rqtemp);
r=sqrt(ri.^2+rq.^2);
mean=sum(r)/2001;
% subplot(3,1,i);
% plot(3,1)
time=0:0.001:2;
plot(time,(10*log10(r)-10*log10(mean)));
titlename=['fd= ' int2str(fm(i)) ' Hz'];
title(titlename);
xlabel('time(second)');
ylabel('Envelope(dB)');
pause
end

2 Commenti

Comment by Bruno Brito mistakenly posted as an Answer:
I am getting the same problem
I have the same problem here on Linux platform, matlab2019a. Some other functions in the graphics toolbox folder are missing as well.

Accedi per commentare.

Risposte (2)

Hi Masroor,
I tried to reset the PATH and rehah the toolbox. Now newplot is usable.
MATLAB moves some functions from the root of graphics folder to axis folder.
So if you update matlab from a previous version. You have to reset the path:
restoredefaultpath
rehash path
rehash toolbox
rehash toolboxcache

2 Commenti

The Answer by Jianning Dong works very well.
I had the same error about variable 'newplot' with Matalb 2019a.
I just typed 'restoredefaultpath' in matlab command window and the plot functions run properly.
'restoredefaultpath' worked for me as well. I had done the 'rehash' steps from above previously, which did not work, but possibly the combination of the two is needed.

Accedi per commentare.

I had a similar issue and I think the culprit is a function called newplot.m.
newplot.m function has subfunctions inside that were not terminated with 'end'.
I added an 'end' statement for each function inside newplot.m:
  • function axReturn = newplot(hsave)
  • function fig = ObserveFigureNextPlot(fig, hsave)
  • function ax = ObserveAxesNextPlot(ax, hsave)
It has worked so far *fingers crossed*.
You can open the file to edit by typing >> open newplot;
I hope this helps.

Prodotti

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by