medanisse
Newbie level 6
I try to calculate a function h (x), starting from the equation of convolution v=h*e
With v and e are two matrices of dimension (1, n) determined by simulation or measurement.
I have treated the problem in the frequency domain as I first determine the Fourier transform of the two matrices v and e, then I calculated the ratio of two transforms
H(ω)=V(ω)./E(ω)
A transformed inverse of H (ω) allows one to determine the matrix h
My problem is that when I load this program in Matlab, with FFT and IFFT functions I get an unstable curve of h(x) with many variations and changes into changing the sampling.
You will find attached a small program in Matlab which gives results.
Can you help me solve this problem which hinders my research for several months.
program :
clc;
clear all;
Ts=0.4; % Sampling unit
x=-50.4:Ts:50.4; %interval calculation
%magnitude v in dB
mag_demi_v=[-51.08 -51.17 -52.03 -54.74 -57.78 -60.21 -62.33 -64.89 -68.39 -73.65 -84.88 -81.77 -79.02 -76.68 -74.70 -73.04 -71.68 -70.58 -69.71 -69.03 -68.53 -68.19 -67.98 -67.88 -67.87 -67.95 -68.09 -68.28 -68.52 -68.80 -69.09 -69.41 -69.74 -70.07 -70.40 -70.73 -71.06 -71.38 -71.68 -71.98 -72.26 -72.53 -72.79 -73.03 -73.27 -73.48 -73.69 -73.89 -74.08 -74.26 -74.43 -74.60 -74.76 -74.92 -75.08 -75.23 -75.39 -75.54 -75.70 -75.86 -76.03 -76.20 -76.37 -76.55 -76.73 -76.92 -77.11 -77.31 -77.52 -77.73 -77.95 -78.17 -78.40 -78.63 -78.86 -79.10 -79.34 -79.58 -79.82 -80.07 -80.31 -80.55 -80.80 -81.04 -81.27 -81.51 -81.74 -81.97 -82.19 -82.41 -82.62 -82.82 -83.04 -83.24 -83.43 -83.62 -83.81 -83.99 -84.17 -84.35 -84.52 -84.69 -84.87 -85.03 -85.20 -85.37 -85.54 -85.71 -85.88 -86.06 -86.23 -86.40 -86.57 -86.75 -86.92 -87.08 -87.25 -87.40 -87.54 -87.67 -87.77 -87.86 -87.91 -87.93 -87.90 -87.82];
mag_v=[fliplr(mag_demi_v) -51.09 mag_demi_v];
%phase v in rad
phase_demi_v=[2.72 2.72 2.72 2.72 2.72 2.72 2.72 2.72 2.72 2.83 -2.89 -1.80 -0.55 -0.44 -0.44 -0.44 -0.45 -0.45 -0.45 -0.45 -0.46 -0.46 -0.46 -0.46 -0.47 -0.47 -0.47 -0.48 -0.48 -0.48 -0.48 -0.49 -0.4925 -0.4949 -0.4973 -0.4996 -0.5019 -0.5042 -0.5 -0.50 -0.51 -0.51 -0.51 -0.51 -0.51 -0.52 -0.52 -0.52 -0.52 -0.52 -0.53 -0.53 -0.53 -0.53 -0.53 -0.54 -0.54 -0.54 -0.54 -0.54 -0.54 -0.54 -0.55 -0.55 -0.55 -0.55 -0.55 -0.55 -0.55 -0.56 -0.56 -0.56 -0.56 -0.56 -0.56 -0.56 -0.56 -0.56 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57];
phase_v=[fliplr(phase_demi_v) 2.72 phase_demi_v];
%complex expression of v
v = mag_v.*exp(i*phase_v);
%display module and phase of v
figure,plot(x,mag_v);grid on;title('magnitude v in dB')
figure,plot(x,phase_v);grid on;title('phase v in rad')
%magnitude e
mag_e_demi=1.0e+003 *[3.1266 2.8455 1.2288 0.1199 0.2414 0.4976 0.5327 0.5061 0.4616 0.4042 0.3575 0.2928 0.2832 0.2490 0.2214 0.1983 0.1809 0.1640 0.1489 0.1348 0.1208 0.1141 0.1050 0.0967 0.0903 0.0840 0.0784 0.0735 0.0692 0.0652 0.0613 0.0579 0.0550 0.0522 0.0496 0.0472 0.0449 0.0427 0.0410 0.0393 0.0376 0.0361 0.0346 0.0333 0.0320 0.0308 0.0296 0.0286 0.0276 0.0267 0.0257 0.0248 0.0240 0.0232 0.0225 0.0218 0.0211 0.0205 0.0198 0.0193 0.0187 0.0182 0.0177 0.0172 0.0167 0.0163 0.0158 0.0154 0.0151 0.0147 0.0143 0.0140 0.0137 0.0134 0.0131 0.0128 0.0125 0.0122 0.0119 0.0117 0.0115 0.0112 0.0110 0.0108 0.0106 0.0104 0.0102 0.0100 0.0098 0.0096 0.0095 0.0093 0.0092 0.0090 0.0089 0.0087 0.0086 0.0085 0.0083 0.0082 0.0081 0.0080 0.0079 0.0078 0.0077 0.0076 0.0075 0.0074 0.0073 0.0072 0.0071 0.0071 0.0070 0.0069 0.0068 0.0068 0.0067 0.0066 0.0066 0.0065 0.0065 0.0064 0.0064 0.0063 0.0063 0.0063 ];
mag_e=[fliplr(mag_e_demi) 3691.2 mag_e_demi];
%phase e in rad
phas_e_demi=[-1.9245 -1.9135 -1.9440 -1.3167 1.3270 1.2113 1.2098 1.2089 1.2131 1.2111 1.2147 1.2157 1.2118 1.2131 1.2122 1.2110 1.2099 1.2066 1.2057 1.2055 1.2038 1.2027 1.2038 1.2026 1.2014 1.2003 1.1989 1.1977 1.1968 1.1951 1.1940 1.1923 1.1906 1.1896 1.1871 1.1848 1.1832 1.1811 1.1789 1.1768 1.1743 1.1715 1.1692 1.1666 1.1639 1.1607 1.1563 1.1551 1.1524 1.1485 1.1448 1.1427 1.1386 1.1352 1.1314 1.1278 1.1240 1.1202 1.1160 1.1126 1.1084 1.1042 1.0999 1.0951 1.0910 1.0868 1.0819 1.0775 1.0726 1.0677 1.0632 1.0581 1.0530 1.0479 1.0428 1.0374 1.0318 1.0264 1.0209 1.0155 1.0098 1.0043 0.9984 0.9926 0.9866 0.9808 0.9744 0.9683 0.9620 0.9554 0.9491 0.9424 0.9354 0.9288 0.9222 0.9153 0.9083 0.9012 0.8942 0.8872 0.8797 0.8729 0.8655 0.8582 0.8506 0.8430 0.8352 0.8275 0.8197 0.8117 0.8038 0.7955 0.7878 0.7795 0.7711 0.7631 0.7545 0.7461 0.7377 0.7293 0.7207 0.7122 0.7034 0.6945 0.6857 0.6767];
phase_e=[fliplr(phas_e_demi) -1.926 phas_e_demi];
%display module and phase of e
figure,plot(x,20*log10(mag_e));grid on;title('magnitude e')
figure,plot(x,phase_e);grid on;title('phase e')
%complex expression of e
e = mag_e.*exp(i*phase_e);
%calculation of the function h
f=fftshift(ifft((fft(v)./fft(e))));
%display module and phase of h
figure;plot(x,abs(f));grid on;title('magnitude of h ')
figure;plot(x,angle(f));grid on;title('phase of h')
Best regards,
With v and e are two matrices of dimension (1, n) determined by simulation or measurement.
I have treated the problem in the frequency domain as I first determine the Fourier transform of the two matrices v and e, then I calculated the ratio of two transforms
H(ω)=V(ω)./E(ω)
A transformed inverse of H (ω) allows one to determine the matrix h
My problem is that when I load this program in Matlab, with FFT and IFFT functions I get an unstable curve of h(x) with many variations and changes into changing the sampling.
You will find attached a small program in Matlab which gives results.
Can you help me solve this problem which hinders my research for several months.
program :
clc;
clear all;
Ts=0.4; % Sampling unit
x=-50.4:Ts:50.4; %interval calculation
%magnitude v in dB
mag_demi_v=[-51.08 -51.17 -52.03 -54.74 -57.78 -60.21 -62.33 -64.89 -68.39 -73.65 -84.88 -81.77 -79.02 -76.68 -74.70 -73.04 -71.68 -70.58 -69.71 -69.03 -68.53 -68.19 -67.98 -67.88 -67.87 -67.95 -68.09 -68.28 -68.52 -68.80 -69.09 -69.41 -69.74 -70.07 -70.40 -70.73 -71.06 -71.38 -71.68 -71.98 -72.26 -72.53 -72.79 -73.03 -73.27 -73.48 -73.69 -73.89 -74.08 -74.26 -74.43 -74.60 -74.76 -74.92 -75.08 -75.23 -75.39 -75.54 -75.70 -75.86 -76.03 -76.20 -76.37 -76.55 -76.73 -76.92 -77.11 -77.31 -77.52 -77.73 -77.95 -78.17 -78.40 -78.63 -78.86 -79.10 -79.34 -79.58 -79.82 -80.07 -80.31 -80.55 -80.80 -81.04 -81.27 -81.51 -81.74 -81.97 -82.19 -82.41 -82.62 -82.82 -83.04 -83.24 -83.43 -83.62 -83.81 -83.99 -84.17 -84.35 -84.52 -84.69 -84.87 -85.03 -85.20 -85.37 -85.54 -85.71 -85.88 -86.06 -86.23 -86.40 -86.57 -86.75 -86.92 -87.08 -87.25 -87.40 -87.54 -87.67 -87.77 -87.86 -87.91 -87.93 -87.90 -87.82];
mag_v=[fliplr(mag_demi_v) -51.09 mag_demi_v];
%phase v in rad
phase_demi_v=[2.72 2.72 2.72 2.72 2.72 2.72 2.72 2.72 2.72 2.83 -2.89 -1.80 -0.55 -0.44 -0.44 -0.44 -0.45 -0.45 -0.45 -0.45 -0.46 -0.46 -0.46 -0.46 -0.47 -0.47 -0.47 -0.48 -0.48 -0.48 -0.48 -0.49 -0.4925 -0.4949 -0.4973 -0.4996 -0.5019 -0.5042 -0.5 -0.50 -0.51 -0.51 -0.51 -0.51 -0.51 -0.52 -0.52 -0.52 -0.52 -0.52 -0.53 -0.53 -0.53 -0.53 -0.53 -0.54 -0.54 -0.54 -0.54 -0.54 -0.54 -0.54 -0.55 -0.55 -0.55 -0.55 -0.55 -0.55 -0.55 -0.56 -0.56 -0.56 -0.56 -0.56 -0.56 -0.56 -0.56 -0.56 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.58 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57 -0.57];
phase_v=[fliplr(phase_demi_v) 2.72 phase_demi_v];
%complex expression of v
v = mag_v.*exp(i*phase_v);
%display module and phase of v
figure,plot(x,mag_v);grid on;title('magnitude v in dB')
figure,plot(x,phase_v);grid on;title('phase v in rad')
%magnitude e
mag_e_demi=1.0e+003 *[3.1266 2.8455 1.2288 0.1199 0.2414 0.4976 0.5327 0.5061 0.4616 0.4042 0.3575 0.2928 0.2832 0.2490 0.2214 0.1983 0.1809 0.1640 0.1489 0.1348 0.1208 0.1141 0.1050 0.0967 0.0903 0.0840 0.0784 0.0735 0.0692 0.0652 0.0613 0.0579 0.0550 0.0522 0.0496 0.0472 0.0449 0.0427 0.0410 0.0393 0.0376 0.0361 0.0346 0.0333 0.0320 0.0308 0.0296 0.0286 0.0276 0.0267 0.0257 0.0248 0.0240 0.0232 0.0225 0.0218 0.0211 0.0205 0.0198 0.0193 0.0187 0.0182 0.0177 0.0172 0.0167 0.0163 0.0158 0.0154 0.0151 0.0147 0.0143 0.0140 0.0137 0.0134 0.0131 0.0128 0.0125 0.0122 0.0119 0.0117 0.0115 0.0112 0.0110 0.0108 0.0106 0.0104 0.0102 0.0100 0.0098 0.0096 0.0095 0.0093 0.0092 0.0090 0.0089 0.0087 0.0086 0.0085 0.0083 0.0082 0.0081 0.0080 0.0079 0.0078 0.0077 0.0076 0.0075 0.0074 0.0073 0.0072 0.0071 0.0071 0.0070 0.0069 0.0068 0.0068 0.0067 0.0066 0.0066 0.0065 0.0065 0.0064 0.0064 0.0063 0.0063 0.0063 ];
mag_e=[fliplr(mag_e_demi) 3691.2 mag_e_demi];
%phase e in rad
phas_e_demi=[-1.9245 -1.9135 -1.9440 -1.3167 1.3270 1.2113 1.2098 1.2089 1.2131 1.2111 1.2147 1.2157 1.2118 1.2131 1.2122 1.2110 1.2099 1.2066 1.2057 1.2055 1.2038 1.2027 1.2038 1.2026 1.2014 1.2003 1.1989 1.1977 1.1968 1.1951 1.1940 1.1923 1.1906 1.1896 1.1871 1.1848 1.1832 1.1811 1.1789 1.1768 1.1743 1.1715 1.1692 1.1666 1.1639 1.1607 1.1563 1.1551 1.1524 1.1485 1.1448 1.1427 1.1386 1.1352 1.1314 1.1278 1.1240 1.1202 1.1160 1.1126 1.1084 1.1042 1.0999 1.0951 1.0910 1.0868 1.0819 1.0775 1.0726 1.0677 1.0632 1.0581 1.0530 1.0479 1.0428 1.0374 1.0318 1.0264 1.0209 1.0155 1.0098 1.0043 0.9984 0.9926 0.9866 0.9808 0.9744 0.9683 0.9620 0.9554 0.9491 0.9424 0.9354 0.9288 0.9222 0.9153 0.9083 0.9012 0.8942 0.8872 0.8797 0.8729 0.8655 0.8582 0.8506 0.8430 0.8352 0.8275 0.8197 0.8117 0.8038 0.7955 0.7878 0.7795 0.7711 0.7631 0.7545 0.7461 0.7377 0.7293 0.7207 0.7122 0.7034 0.6945 0.6857 0.6767];
phase_e=[fliplr(phas_e_demi) -1.926 phas_e_demi];
%display module and phase of e
figure,plot(x,20*log10(mag_e));grid on;title('magnitude e')
figure,plot(x,phase_e);grid on;title('phase e')
%complex expression of e
e = mag_e.*exp(i*phase_e);
%calculation of the function h
f=fftshift(ifft((fft(v)./fft(e))));
%display module and phase of h
figure;plot(x,abs(f));grid on;title('magnitude of h ')
figure;plot(x,angle(f));grid on;title('phase of h')
Best regards,