Issue with multiple If condition
Mostra commenti meno recenti
Hello, I have an issue with the if condition.
I have the following values for the case I have the issue
P_matrix=[53.9350, 53.95, 54125];
S_matrix=[-1, 60.485, 60.57];
TS_arrival_lag=5.3257;
TS_checking=0.9*TS_arrival_lag;
This is the code. The part that is bolted was added to identify a specific case with another condition to explore more options in the selection of the results. However, when it goes inside the condition it gets out from the entire condition despite the condition is met. I added break points to find out the issue and it works for the line indicated below which the target result when the condition is met. I would appreciate the help.
%% Analysis of the P- and S-wave arrivals
%Sorted P-wave Matrix
P_matrix=[plocx; plocy; plocz];
P_matrix=sort(P_matrix);
% Sorted S-wave Matrix
S_matrix=[slocx; slocy; slocz];
S_matrix=sort(S_matrix);
% Estimating the variance between whole P-wave matrix and the two consecutive maximum values
Var_P_wave1=var(P_matrix);
Var_P_wave2=var([P_matrix(1,1);P_matrix(2,1)]);
Var_P_wave3=var([P_matrix(2,1);P_matrix(3,1)]);
% Estimating the variance between the whole S-wave matrix and the two consecutive maximum values
Var_S_wave1=var(S_matrix);
Var_S_wave2=var([S_matrix(2,1);S_matrix(3,1)]);
Var_S_wave3=var([S_matrix(1,1);S_matrix(2,1)]);
%% Estimation of the P-wave and S-wave for windowing procedure
if Var_P_wave1<1.5 && Var_S_wave1<1.5
Pt=mean(P_matrix);
St=mean(S_matrix);
elseif Var_P_wave1<1.5 && Var_S_wave1>1.5
if Var_S_wave2<1.5 && mean([S_matrix(2,1);S_matrix(3,1)])>=(mean(P_matrix)+0.5*TS_arrival_lag) && mean([S_matrix(2,1);S_matrix(3,1)])<=(mean(P_matrix)+1.5*TS_arrival_lag)
Pt=mean(P_matrix); ____________ (This works by using break points which it the condition met)
St=mean([S_matrix(2,1);S_matrix(3,1)]); _____________(This works by using break points which is the condition met)
elseif Var_S_wave3<1.5 && mean([S_matrix(1,1);S_matrix(2,1)])>=(mean(P_matrix)+0.5*TS_arrival_lag) && mean([S_matrix(1,1);S_matrix(2,1)])<=(mean(P_matrix)+1.5*TS_arrival_lag)
Pt=mean(P_matrix);
St=mean([S_matrix(1,1);S_matrix(2,1)]);
else
Pt=mean(P_matrix);
St=Pt+ TS_checking;
end
elseif Var_P_wave2<1.5 && Var_S_wave2<1.5
Pt=mean([P_matrix(1,1);P_matrix(2,1)]);
St=mean([S_matrix(2,1);S_matrix(3,1)]);
elseif Var_P_wave3<1.5 && Var_S_wave2<1.5
Pt=mean([P_matrix(2,1);P_matrix(3,1)]);
St=mean([S_matrix(2,1);S_matrix(3,1)]);
elseif Var_P_wave2<1.5 && Var_S_wave3<1.5
Pt=mean([P_matrix(1,1);P_matrix(2,1)]);
St=mean([S_matrix(1,1);S_matrix(2,1)]);
elseif Var_P_wave3<1.5 && Var_S_wave3<1.5
Pt=mean([P_matrix(2,1);P_matrix(3,1)]);
St=mean([S_matrix(1,1);S_matrix(2,1)]);
else
Pt=min(P_matrix);
St=max(S_matrix);
end
2 Commenti
Torsten
il 18 Ago 2023
We cannot check your claim because you didn't include executable code.
Jorge Luis Paredes Estacio
il 18 Ago 2023
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su MATLAB in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!