How can I delete values from a matrix?
4 ビュー (過去 30 日間)
古いコメントを表示
Azra Ferhatbegovic
2015 年 2 月 14 日
コメント済み: Azra Ferhatbegovic
2015 年 2 月 17 日
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 :)
0 件のコメント
採用された回答
Geoff Hayes
2015 年 2 月 14 日
編集済み: Geoff Hayes
2015 年 2 月 14 日
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,:) = [];
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!