The output value of the for loop is wrong
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
rajasekar dhandapani
am 19 Jun. 2019
Kommentiert: Bob Thompson
am 19 Jun. 2019
Hi all,
The output structure is right but somehow the logic is wrong
please find the script below
D_Calc=[];
Filter=[];
for jj=1:12
D_Calc(:,end+1)=D(:,jj); % both D_Calc and D are same
Filter=D_Calc(D_Calc(:,jj)<PlusThreesigma(jj))
MeanFilter(:,end+1)=mean(Filter);
end
output
The filter and the mean filter value takes only the 1st column.
4 Kommentare
Bob Thompson
am 19 Jun. 2019
Ok, I was able to run your code, and I am not seeing the problem you are mentioning. For me, MeanFilter is coming out as a single row of values, with corresponding means in each column.
Akzeptierte Antwort
Bob Thompson
am 19 Jun. 2019
I see it now. Swap the Filter line for the following.
Filter=D_Calc(D_Calc(:,jj)<PlusThreesigma(jj),jj);
Basically, your logic produces the logic for one column, but because a specific column of D_Calc was not specified it was always looking at the first column.
2 Kommentare
Bob Thompson
am 19 Jun. 2019
To use more than one logical condition, use & for and, and | for or.
Filter = D_Calc(D_Calc(:,jj)>MinusThreesigma(jj) & D_Calc(:,jj)<PlusThreesigma(jj),jj)
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!