i am getting only the last figure as output but i need all the 4 of them separately
조회 수: 1 (최근 30일)
이전 댓글 표시
% % Design and Analysis of higher order fractional step
% % Butterworth filters
clear all;
clc;
close all;
warning off
%-----------BUTTERWORTH FILTER-------------------------------
Hl=zeros(512,512);% input=imread('filename.fileformat');
[B1 B2]=size(Hl);
Hh=zeros(512,512);
[W1 W2]=size(Hl);
M=512;N=512;dl=30;dh=120;n=2;
Wp = dl/B1;
Ws = dh/W1;
[n,Wn] = buttord(Wp,Ws,3,60);
[z,p,k] = butter(n,Wn);
sos = zp2sos(z,p,k);
for(u=1:M)
for(v=1:N)
D(u,v)=((u-(M/2))^2 + (v-(N/2))^2 )^(1/2);
Hl(u,v)=1/(1 + ((D(u,v)/dl)^(2*n)) );
end
end
% % % figure; imshow(Hl,[]);
for(u=1:M)
for(v=1:N)
D(u,v)=((u-(M/2))^2 + (v-(N/2))^2 )^(1/2);
Hh(u,v)=1/(1 + ((D(u,v)/dh)^(2*n)) );
end
end
Hhh=1-Hh;
H=Hh-Hl;
I_img=imresize(Hhh,[M N]);
F=fftshift(fft2(double(I_img)));
%-----------butter low pass filter---------------------------
G=fftshift(Hl.*F);
bw1=real(ifft2(double(G)));
[a,k,j]=size(bw1);
[z,p,k] = butter(n,Wn);
lpf1=j+z(1);
lpf2=-(((real(p(5))*n)*(n*(j+j)))-j);
lpf3=lpf2*(j+j);
lpf4=-((a/(n-1))-(j+j+j));
lpf5=(lpf4-n);
lpf6=(lpf2*(n+(j+j))+j);
lpf7=(((lpf2*(n*(j+j)))+lpf4)+j);
%-----------butter high pass filter--------------------------
G1=fftshift(Hhh.*F);
bw2=real(ifft2(double(G)));
[z,p,k] = butter(n,Wn);
hpf1=j+z(1);
hpf2=-(real(p(5))*(j+j)*(n*(j+j))+j);
hpf3=(hpf2*(j+j))-(j+j+j);
hpf4=-((real(p(1))*(n+1))*(n*(j+j))+n);
hpf5=hpf4/(j+j);
hpf6=(hpf5+hpf4)+(j+j+j);
G2=fftshift(H.*F);
bw3=real(ifft2(double(G)));
[z,p,k] = butter(n,Wn);
figure%%-----------------------------------------------(1)
x=[-3:1:3];
existing1
lbf_design=[lpf1 lpf1 lpf1 lpf1 lpf2 lpf3 lpf4];
plot(x,y1,'g-*','Linewidth',2','MarkerFacecolor','g','Markersize',5);
hold on
plot(x,y2,'r--*','Linewidth',2','MarkerFacecolor','r','Markersize',5);
hold on
plot(x,y3,'b-->','Linewidth',2','MarkerFacecolor','b','Markersize',5);
hold on
plot(x,y4,'m--*','Linewidth',2','MarkerFacecolor','m','Markersize',5);
hold on
plot(x,lbf_design,'y->','Linewidth',2','MarkerFacecolor','c','Markersize',5);
ylim([-100,10]);
xlabel('freqency(rad/sec)[-3=10^-3;-2=10^-2;-1=10^-1;0=10^0;1=10^1;2=10^2;3=10^3]');
ylabel('magnitude(dB)');
title('magnitude responses of fractional low pass filters of order 1,1.2,1.4,1.8,2');
legend('order 1','order 1.2','order 1.4','order 1.8','order 2')
hold off
grid on
figure%%------------------------------------------------------(3)
x=[-3:1:3];
existing2
lbf_design_data=[lpf1 lpf1 lpf1 lpf1 lpf5 lpf6 lpf7];
plot(x,y1,'g-*','Linewidth',2','MarkerFacecolor','g','Markersize',5);
hold on
plot(x,y2,'r--*','Linewidth',2','MarkerFacecolor','r','Markersize',5);
hold on
plot(x,y3,'b-->','Linewidth',2','MarkerFacecolor','b','Markersize',5);
hold on
plot(x,y4,'m--*','Linewidth',2','MarkerFacecolor','m','Markersize',5);
hold on
plot(x,lbf_design_data,'y-->','Linewidth',2','MarkerFacecolor','c','Markersize',5);
ylim([-180,10]);
xlabel('freqency(rad/sec)[-3=10^-3;-2=10^-2;-1=10^-1;0=10^0;1=10^1;2=10^2;3=10^3]');
ylabel('magnitude(dB)');
title('magnitude responses of fractional low pass filters of order 1.4,3.4,4.4,5.4,6.4');
legend('order 1.4','order 3.4','order 4.4','order 5.4','order 6.4')
hold off
figure%%---------------------------------------------------(5)
x=[-3:1:3];
hbf_design_data=[hpf4 hpf3 hpf2 hpf1 hpf1 hpf1 hpf1];
existing3
plot(x,hbf_design_data,'y-*','Linewidth',2','MarkerFacecolor','g','Markersize',5);
hold on
plot(x,y2,'r--*','Linewidth',2','MarkerFacecolor','r','Markersize',5);
hold on
plot(x,y3,'b-->','Linewidth',2','MarkerFacecolor','b','Markersize',5);
hold on
plot(x,y4,'m--*','Linewidth',2','MarkerFacecolor','m','Markersize',5);
hold on
plot(x,y5,'c->','Linewidth',2','MarkerFacecolor','c','Markersize',5);
ylim([-100,10]);
xlabel('freqency(rad/sec)[-3=10^-3;-2=10^-2;-1=10^-1;0=10^0;1=10^1;2=10^2;3=10^3]');
ylabel('magnitude(dB)');
title('magnitude responses of fractional high pass filters of order 1,1.2,1.4,1.8,2');
legend('order 1','order 1.2','order 1.4','order 1.8','order 2')
hold off
figure%%--------------------------------------------------(7)
x=[-3:1:3];
hbf_design=[hpf6 hpf4 hpf5 hpf1 hpf1 hpf1 hpf1];
existing4
plot(x,hbf_design,'y-*','Linewidth',2','MarkerFacecolor','g','Markersize',5);
hold on
plot(x,y2,'r--*','Linewidth',2','MarkerFacecolor','r','Markersize',5);
hold on
plot(x,y3,'b-->','Linewidth',2','MarkerFacecolor','b','Markersize',5);
hold on
plot(x,y4,'m--*','Linewidth',2','MarkerFacecolor','m','Markersize',5);
hold on
plot(x,y5,'c-->','Linewidth',2','MarkerFacecolor','c','Markersize',5);
ylim([-180,10]);
xlabel('freqency(rad/sec)[-3=10^-3;-2=10^-2;-1=10^-1;0=10^0;1=10^1;2=10^2;3=10^3]');
ylabel('magnitude(dB)');
title('magnitude responses of fractional high pass filters of order 1.4,3.4,4.4,5.4,6.4');
legend('order 1.4','order 3.4','order 4.4','order 5.4','order 6.4')
hold off
댓글 수: 3
Jos (10584)
2019년 3월 7일
You only need to set the hold state once. It is like a toggle switch:
hold on
plot(..)
..
plot(..)
hold off
This will not help you, but makes your code easier to read :-)
답변 (2개)
Walter Roberson
2019년 3월 7일
편집: Walter Roberson
2019년 3월 7일
The code executes fine for me once I create existing1, existing2, existing3, and existing4 as assigning values to y1, y2, y3, y4, and y5. All four plots are created.
All four plots are put at the same location on the screen for me, so I have to move the top one to see the one below it.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Filter Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!