78 lines
1.5 KiB
Matlab
78 lines
1.5 KiB
Matlab
clc;
|
|
clear all;
|
|
close all;
|
|
|
|
F1 = 85000;
|
|
% F1 = 85005.9;
|
|
F2 = 90000;
|
|
%F3 = 95000;
|
|
F3 = 94986.8;
|
|
F4 = 100000;
|
|
%F5 = 115000;
|
|
F5 = 115015.9;
|
|
F6 = 120000;
|
|
|
|
ChebFac0 = 1;
|
|
ChebFac1 = 3.0332e-6;
|
|
ChebFac2 = 1.162e-11;
|
|
ChebFac3 = 7.6663e-18;
|
|
ChebFac4 = 1.7483e-23;
|
|
|
|
Fe=320000;
|
|
Te = 1/Fe;
|
|
|
|
Fsin=120000;
|
|
N=6;
|
|
M=pow2(N);
|
|
T=M*Te;
|
|
|
|
% Condition : T < M/(2*Fsin)
|
|
%T = pow2(N-2)/Fsin;
|
|
%Te = T/M;
|
|
|
|
% harmoniques = arrayfun(@(x) x * 2 * pi * F1, 0:1:5);
|
|
% reponseHarmoniques = arrayfun(@(x) chebychev(x), harmoniques);
|
|
% loglog(harmoniques, reponseHarmoniques);
|
|
|
|
Tsim = T-Te;
|
|
res=sim('Simul6PistoletsDFT.slx');
|
|
|
|
|
|
|
|
%plot(res.Echant.Data);
|
|
|
|
F=linspace(0, Fe-Fe/M, M);
|
|
% mauvais_echantillon = res.Echant.Data;
|
|
% for i = 1:floor((length(mauvais_echantillon) / 2))
|
|
% mauvais_echantillon(i) = 0;
|
|
% end
|
|
% fourier = abs(fft(mauvais_echantillon)/M);
|
|
|
|
|
|
% filteredSignal = arrayfun(@(x) chebychev(x), res.Echant.Data);
|
|
% fourier = abs(fft(filteredSignal)/M);
|
|
|
|
|
|
fourier=abs(fft(res.Echant.Data)/M);
|
|
|
|
%res=sim('SimulDFT.slx');
|
|
%fourier=fft(res.Sinus_Echantillon.Data)/M;
|
|
%fourier = real(fourier * (1i));
|
|
% bode(tf(F,arrayfun(@(x) chebychev(x), F)));
|
|
|
|
% grid;
|
|
% stem(F, fourier, 'o');
|
|
% set(gca, 'YScale', 'log');
|
|
plot(res.Echant);
|
|
%plot(res.Sinus_Continu);
|
|
%hold on; % permet de superposer la courbe à suivre
|
|
% plot(res.Sinus_Echantillon,'o');
|
|
|
|
function filtre = chebychev(p)
|
|
ChebFac0 = 1;
|
|
ChebFac1 = 3.0332e-6;
|
|
ChebFac2 = 1.162e-11;
|
|
ChebFac3 = 7.6663e-18;
|
|
ChebFac4 = 1.7483e-23;
|
|
filtre = 1 / (ChebFac4 * p^4 + ChebFac3 * p^3 + ChebFac2 * p^2 + ChebFac1 * p + ChebFac0);
|
|
end
|