Why two different ways of expressing the same logical condition lead to two different results ???
Mostra commenti meno recenti
I run two codes with a little difference in the way I express logical conditions, namely:
In code 1: I write : A(k,4) > B(:,2) & B(:,2)> A(k,3) In code 2: I write : A(k,4) > B(:,2) > A(k,3)
But in code 1 I have the expected result and in code 2, i do not.
Here are two full code I used:
Code 1:
clear all clc A=xlsread('criteria.xlsx'); B=xlsread('panel.xlsx');
for i=1:89 for j=1:64 for k=1:3 for h=1:2 mask = B(:,5) == A(i,1) & B(:,4) == A(j,2) & A(k,4) > B(:,2) & B(:,2)> A(k,3) & A(h,5) < B(:,1) < A(h,6);
x = mean(B(mask,3));
B(mask,5) = x;
y = std(B(mask,3));
B(mask,6) = y;
end
end
end
end
xlswrite('panel.xlsx',B)
Code 2:
clear all clc A=xlsread('criteria.xlsx'); B=xlsread('panel.xlsx');
for i=1:89 for j=1:64 for k=1:3 for h=1:2 mask = B(:,5) == A(i,1) & B(:,4) == A(j,2) & A(k,4) > B(:,2) > A(k,3) & A(h,5) < B(:,1) < A(h,6);
x = mean(B(mask,3));
B(mask,7) = x;
y = std(B(mask,3));
B(mask,8) = y;
end
end
end
end
xlswrite('panel.xlsx',B)
In order to see the difference in result, I save the output from code 1 into column 5, 6 and the output from code 2 into column 7, 8 both in file panel.xlsx.
Please run these two codes with two attached excel files and help me, thanks!
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Neighborhood and Block Processing 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!