Question

I am new in Matlab I hope this question worth it. I have 2 sets of numbers. a=[0;0.01;0.02;0.03;...] (4187*1) b=[0;0.3;0.4;0.1;0.23;...] (4187*1) By defining f=[a b] (4187*2) Matrix I want to filter my rows by condition on b value (b>0.05) and I want to see the results in (a b) format. Can you help me on writing this program?

Was it helpful?

Solution

If you want to filter your rows depending on values in b then you can do this:

f = [a,b];
f = f((f(:,2)<=0.05),:);

This will keep all of the values less than or equal to 0.05 based on the values from b. This is assuming you want to delete all the rows of b>0.05

If you want to keep the values of b>0.05 then you would use this:

f = [a,b];
f = f((f(:,2)>0.05),:);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top