conditional deletion of riws
Show older comments
Dear Matlab users, I am writing a matlab script to delete some rows based on some condition. I want to look for some symmetric matrix around a diagonal line of "ones"
(1). I want, in each row, to look for elements which are > 0.7 but less than 1.0.
if there is a value in row "i" and column "j" which satisfies this condition. There should be cell with the same value in row "j" and column "i".
I want to compare these two rows (for each case the conditions are satisfied) and delete the one that has the larger value in the last column for each.
I am writing the script shown below but it does not delete any line and I do not understand why. Would you please advice????? Regards Shireen
M = xlsread('test.xlsx');
[r,c]=size(M);
for i =1:r,
for j=1:c-1
if (M(i,j) >= 0.7) & (M(i,j)<0.1) % get row and column index of points > 0.7
M(i,c)
M(j,c)
if M(i,c)>M(j,c)
nM(i,:)=[ ] % delete the row with the larger "c" value
else
nM(j,:)=[ ]
end
end
end
end
Accepted Answer
More Answers (1)
dpb
on 9 Nov 2014
if (M(i,j)>=0.7) & (M(i,j)<0.1)
The above is impossible...you wrote "0.1" for "1.0" in the second comparison
Categories
Find more on Common Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!