Voici le code un peu "bestial" réalisé:
clc
clear
% Parameters
Path_number=4; % Number of MPA paths
Random_number=300; % Number of random trials
Random_std=2; % Amplitude standard deviation of the random trials (dB)
Random_mean=0;
Amplitude_bit=7; % Bit number of digital attenuator
Amplitude_range=32; % Range of the digital attenuator (dB)
Amplitude_step=Amplitude_range/(2^Amplitude_bit); % Step of digital attenuator (dB)
Sigma_goal=0.2; % Amplitude standard deviation max. expected (dB)
% Initialization of paths Amplitude
Amp_1_path=0; Amp_2_path=0; Amp_3_path=0;
Amp_final_path=0; Amp_final_paths=0;
Random_Amplitude=0;
Sigma_before=0;
Summary_sigma_before=0; Summary_sigma_after=0;
All_Amplitudes=zeros(1,Path_number);
% Random trials
for i=1:Random_number
Random_Amplitude=random('Normal',Random_mean,Random_std,1,Path_number); % Random trial initialization
Sigma_before(i)=std(Random_Amplitude,1); % Initial amplitude standard deviation before optimization
Amp_final_path=0; A=0; B=0; C=0; D=0; E=0; F=0;
Amp_final_path(1)=Random_Amplitude(1); % First amplitude of trial is kept
for j=2
![:P](https://www.developpez.net/forums/images/smilies/icon_razz.gif)
ath_number
Amp_1_path= Random_Amplitude(j)-(round((Random_Amplitude(j)-mean(Amp_final_path))/Amplitude_step))*Amplitude_step;
Amp_2_path= Random_Amplitude(j)-(round((Random_Amplitude(j)-mean(Amp_final_path))/Amplitude_step)+1)*Amplitude_step;
Amp_3_path= Random_Amplitude(j)-(round((Random_Amplitude(j)-mean(Amp_final_path))/Amplitude_step)-1)*Amplitude_step;
A=[Amp_final_path Amp_1_path]; B=[Amp_final_path Amp_2_path]; C=[Amp_final_path Amp_3_path];
D=std(A,1); E=std(B,1); F=std(C,1);
if D<=E
if D<=F
Amp_final_path(j)=Amp_1_path;
else
Amp_final_path(j)=Amp_3_path;
end
else
if E<=F
Amp_final_path(j)=Amp_2_path;
else
Amp_final_path(j)=Amp_3_path;
end
end
end
Amp_initial_paths=Random_Amplitude;
Amp_final_paths=Amp_final_path;
Summary_sigma_before=Sigma_before;
Summary_sigma_after(i)=std(Amp_final_paths,1);
All_Amplitudes=[All_Amplitudes;Amp_initial_paths];
end
All_Amplitudes(1,
![:)](https://www.developpez.net/forums/images/smilies/icon_smile.gif)
=[];
Summary_sigma_before;
Summary_sigma_after;
A part cette méthode itérative, je n'arrive pas à mettre en équation l'optimisation voulue. Je suis preneur de toute autre piste...Merci!
Partager