Reputation:
let us consider following code
function [order]=find_order(y,fs);
order=0;
n=length(y);
n1=nextpow2(n);
ndft=2^n1;
for i=1:floor(n/2)
[Pxx,f]=pburg(y,i,ndft,fs);
% subplot(floor(n/2),floor(n/2),i);
%subplot(ndft,ndft,i);
h = figure;
plot(f,Pxx);
title(['order',num2str(i),'i']);
filename = 'mydata';
print(h, '-dpsc', filename);
order(i)=i;
pause(6.21);
end
end
i have one question want instead of at each iteration plot new graph,replace old one by new one,so how can i do it?please help me
Upvotes: 0
Views: 89
Reputation: 5359
In your for loop you are calling for a new figure with every iteration with h = figure
. If you really want to keep the function call, move it to outside the for loop
function [order]=find_order(y,fs);
order=0;
n=length(y);
n1=nextpow2(n);
ndft=2^n1;
h = figure;
for i=1:floor(n/2)
[Pxx,f]=pburg(y,i,ndft,fs);
% subplot(floor(n/2),floor(n/2),i);
%subplot(ndft,ndft,i);
plot(f,Pxx);
title(['order',num2str(i),'i']);
filename = 'mydata';
print(h, '-dpsc', filename);
order(i)=i;
pause(6.21);
end
end
Upvotes: 1