Created
July 10, 2009 04:04
-
-
Save vincentchu/144233 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% loop over every row in exclusion array | |
for i=1:size(exclusionarray, 1) | |
curr_row = exclusionarray(i, :); | |
% find the rows in test where the condition is satisfied, using the first | |
% two columns of excl. array as the criterion | |
% replace the third column of the right row in test with the third col of | |
% the current row in excl. array | |
for j=1:size(test, 1) | |
if (test(j, 1) == curr_row(i, 1) & test(j, 2) == curr_row(i, 2)) | |
test(j, 3) = curr_row(i, 3); | |
end | |
end | |
end | |
for i=1:size(exclusionarray, 1) | |
curr_row = exclusionarray(i, :); | |
% find me all rows where the first col of test is equal to the first | |
% element of curr_row. | |
% then find me all rows where the second col of test is equal to the | |
% second element of curr_row | |
% then find rows in both lists. these are the rows where we want to | |
% make replacement with curr_row(3) | |
rows1and2 = intersect(find(test(:, 1) == curr_row(1)) , find(test(:, 2) == curr_row(2))); | |
test(rows1and2, 3) = curr_row(3); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment