How can I delete values from a matrix?

Hello I've just started using Matlab few months ago so I hope somebody can help me with my problem. My problem is that I have some flow measurements, and I need to remove all values below 0.01 l/s, so Q>0.01 l/s. It's a large matrix (1135266x3 double), and it still needs to be a matrix with 3 columns after removing the values, so I guess I need to delete rows that contain values from 0.01 and below. I've tried to look it up online but couldn't find anything that works. Thanks :)

 Accepted Answer

Geoff Hayes
Geoff Hayes on 14 Feb 2015
Edited: Geoff Hayes on 14 Feb 2015
Azra - how does your logic of removing elements less than 0.01 apply to the following example
flowData = [1 3 4;
5 0.001 6];
We can use
idcs = find(flowData<0.01);
to find all indices of flowData where there is an element less than 0.01. But, for this example, we can't remove the element else we will no longer have a row of three columns. Can we replace this with NaN instead? Something like
flowData(flowData<0.01) = NaN;
where flowData now becomes
flowData =
1 3 4
5 NaN 6
Or, do we delete the whole row if at least one element is less than 0.01? Something like
% find the rows of flowData that have an element less than 0.01
[rowIdcs, ~] = find(flowData<0.01);
% remove those rows from flowData that have at least one element less than 0.01
flowData(rowIdcs,:) = [];

1 Comment

It's works! Thank you so much!
And, I can use both actually. Thanks once again :)

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics 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!