To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016
I have a matrix with 8 columns and I would like to delete those rows where the value of column 8 exceeds 1.1 or is below 0.9 and apply a similar criteria on column 5, here is the respective code:
while i < size(data8, 1) i = i + 1 ; if(data8(i,8)>1.1) data8(i,:) = ; elseif(data8(i,8)<0.9) data8(i,:) = ; elseif(data8(i,5)<5*1/365) data8(i,:) = ; elseif(data8(i,5)>120*1/365) data8(i,:) = ; end end
although the code is running, I get in the resulting matrix values in column 8 that exceeds 1.1 and are below 0.9, whan do I need to change?
No products are associated with this question.
Try it this way
rowsToDelete = data(:,8) > 1.1 | data(:,8) < 0.9; data(rowsToDelete, :) = ;
Do the same for column #5. You could combine column 5 into the calculation of rowsToDelete if you want.
awesome, this is working. Could you shortly explain me what rowsToDelete is doing? I get just zeros and from what I know zero means false, but I don't understand the logic behind it.
What is the | operator doing? is that the same as &...?
Thanks vermy much for the help!