# I'm trying to figure out why after i run this code I'm not getting any messages and no plots are popping up

조회 수: 3(최근 30일)
Cheryl 2013년 12월 16일
답변: VBBV 2021년 11월 15일
if true
%close all
clear all
num_fft=1024;
dt=1;
f= [ 0 0 0 0 1 0 0.5 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0]
h=[ 2.76077e-006 0.000746586 0.0407636 0.449702 1.02038 0.673993 0.540762,... 0.225414 0.0211304 0.0411355 0.44933 1 0.449329 0.040762 0.000746586,... 2.76077e-006 0 0 0 0 0 0 0 0]
N= numel(h);
for i = 1:N
x(i)=(i-1);
H=fft(h,num_fft); %Take the FFT of h
for j=1:num_fft;
dfh(j)=(((1/num_fft*dt))*(j-1))-0.5;%Calculate frequency bins for H
end
HR=real(H);%Calculate real part of H;
HI=image(H);%Calculate imaginary part of H;
for i=1:num_fft;
HM(i)=sqrt((HR(i)^2)+((HI(i)^2)));%calculate magnitude of H components
end
figure(1)
plot((dfh),fftshift(HM),'k');
title('Magnitude of H');
xlabel('freq axis')
ylabel('Magnitude axis');
Htheta = fftshift(atan2(HI,HR));% Calculate the phase for H
figure (2)
plot(dfh,unwrap((Htheta),.1),'k');
title('Phase Angle of H');
xlabel('freq axis')
ylabel('Phase axis')
F=fft(f,num_fft); %Take the FFT of f
for j=1:num_fft
dfg(j)=(((1/num_fft*dt))*(j-1))-0.5;%Calculate frequency bins for F
end
FR=real(F);
FI=image(F);
for i=1:num_fft;
FM(i)=sqrt((FR(i)^2)+((FI(i)^2)));%Calculate magnitude of F components
end
figure(3)
plot((dfh),fftshift(FM),'k');
title('Magnitude of F');
xlabel('Freq axis');
ylabel('Phase axis');
FH=H
for i=1:num_fft;
if FM== 0;
FDF(i)=0;
else
FDF(i)=FH(i)./F(i);
end
end
for j=1:num_fft;
dfg(j)=(((1/num_fft*dt))*(j-1))-0.5;
end
GDFR=real(GDF);%calculate the real part of F;
GDFI=image(GDF);%calculate the imaginary part of F;
for i=1:num_fft;
FDFM(i)=sqrt((GDFR(i)^2)+((GDFI(i)^2)));%Calculate magnitude of F components
end
figure (4)
plot((dfh),fftshift(GDFM),'k');
title('Magnitude of GDF');
xlabel('freq axis')
ylabel('Magnitude axis')
FDFtheta=fftshift(atan2(GDFI,GDFR));%Calculate the phase for F
figure (5)
plot (dfh,unwrap((GDFtheta),.1),'k');
title('Phase Angle of GDF');
xlabel('freq axis');
ylabel('Phase axis');
Fdf=ifft(GDF,num_fft);
Plot(GDF,'k');
title('unknown g')
xlabel('freq axis');
ylabel('Phase axis');
end

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

### 답변(2개)

Image Analyst 2013년 12월 16일
##### 댓글 수: 0표시숨기기 이전 댓글 수: -1

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

VBBV 2021년 11월 15일
clear all
num_fft=1024;
dt=1;
f= [ 0 0 0 0 1 0 0.5 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0]
f = 1×24
0 0 0 0 1.0000 0 0.5000 0 0 0 0 1.0000 0 0 0 0 0 0 0 0 0 0 0 0
h=[ 2.76077e-006 0.000746586 0.0407636 0.449702 1.02038 0.673993 0.540762 0.225414 0.0211304 0.0411355 0.44933 1 0.449329 0.040762 0.000746586 2.76077e-006 0 0 0 0 0 0 0 0]
h = 1×24
0.0000 0.0007 0.0408 0.4497 1.0204 0.6740 0.5408 0.2254 0.0211 0.0411 0.4493 1.0000 0.4493 0.0408 0.0007 0.0000 0 0 0 0 0 0 0 0
N= numel(h);
for i = 1:N
x(i)=(i-1);
H=fft(h,num_fft); %Take the FFT of h
for j=1:num_fft;
dfh(j)=(((1/num_fft*dt))*(j-1))-0.5;%Calculate frequency bins for H
end
HR=real(H);%Calculate real part of H;
HI=imag(H);%Calculate imaginary part of H; function used incorrectly
for i=1:num_fft;
HM(i)=sqrt((HR(i)^2)+((HI(i)^2)));%calculate magnitude of H components
end
figure(1)
plot((dfh),fftshift(HM),'k');
title('Magnitude of H');
xlabel('freq axis')
ylabel('Magnitude axis');
Htheta = fftshift(atan2(HI,HR));% Calculate the phase for H
figure (2)
plot(dfh,unwrap((Htheta),.1),'k');
title('Phase Angle of H');
xlabel('freq axis')
ylabel('Phase axis')
F=fft(f,num_fft); %Take the FFT of f
for j=1:num_fft
dfg(j)=(((1/num_fft*dt))*(j-1))-0.5;%Calculate frequency bins for F
end
FR=real(F);
FI=imag(F); % function used incorrectly
for i=1:num_fft;
FM(i)=sqrt((FR(i)^2)+((FI(i)^2)));%Calculate magnitude of F components
end
figure(3)
plot((dfh),fftshift(FM),'k');
title('Magnitude of F');
xlabel('Freq axis');
ylabel('Phase axis');
FH=H;
for i=1:num_fft;
if FM== 0;
FDF(i)=0;
else
FDF(i)=FH(i)./F(i);
end
end
for j=1:num_fft;
dfg(j)=(((1/num_fft*dt))*(j-1))-0.5;
end
GDFR=real(dfg);%calculate the real part of F;
GDFI=imag(dfg);%calculate the imaginary part of F; function used incorrectly
for i=1:num_fft;
FDFM(i)=sqrt((GDFR(i)^2)+((GDFI(i)^2)));%Calculate magnitude of F components
end
figure (4)
plot((dfh),fftshift(FDFM),'k'); % typo error here
title('Magnitude of GDF');
xlabel('freq axis')
ylabel('Magnitude axis')
FDFtheta=fftshift(atan2(GDFI,GDFR));%Calculate the phase for F
figure (5)
plot (dfh,unwrap((FDFtheta),.1),'k'); % typo error here
title('Phase Angle of GDF');
xlabel('freq axis');
ylabel('Phase axis');
Fdf=ifft(dfg,num_fft);
plot(dfg,'k'); % function call incorrect
title('unknown g')
xlabel('freq axis');
ylabel('Phase axis');
end
Many typographic errors in your code, including usage of functions like Plot- > plot , Image-> imag , imaginary part of function

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

### Community Treasure Hunt

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

Start Hunting!

Translated by