フィルターのクリア

Set points that matches with a vector as NaN

2 ビュー (過去 30 日間)
Philippe Corner
Philippe Corner 2021 年 8 月 12 日
コメント済み: Philippe Corner 2021 年 8 月 17 日
load('var.mat')
scatter3(cy(:,1),cy(:,2),cy(:,3),10,'k','filled');hold on
scatter3(top(:,1),top(:,2),top(:,3),10,'r','filled');
scatter3(bot(:,1),bot(:,2),bot(:,3),10,'r','filled');
whos cy
Name Size Bytes Class Attributes cy 46057x4 1473824 double
cy is a 4 columns matrix, I would like to set all the values of cy(:,4) that matches with the positiones above top vector and below bot vector as NaN values.

採用された回答

Dave B
Dave B 2021 年 8 月 12 日
In this particular case, because they all have the same y value, you can do this quite easily with interp:
scatter3(cy(:,1),cy(:,2),cy(:,3),10,'k','filled');hold on
scatter3(top(:,1),top(:,2),top(:,3),10,'r','filled');
scatter3(bot(:,1),bot(:,2),bot(:,3),10,'r','filled');
ind = cy(:,4) < interp1(bot(:,1),bot(:,3),cy(:,1)) | ...
cy(:,4) > interp1(top(:,1),top(:,3),cy(:,1));
cy(ind,4) = nan;
scatter3(cy(:,1),cy(:,2),cy(:,4),10,'m','filled');hold on
  6 件のコメント
Philippe Corner
Philippe Corner 2021 年 8 月 12 日
Thank you very much for your help. And this approah using interp1 is very interesting idea to solve this task.
Best wishes!
Philippe Corner
Philippe Corner 2021 年 8 月 17 日
Hi Dave, this quiestion is very similar tham this one, but im confused about how to use it for all X, Y, Z positons. If you can give a hand it would be highly appreciated! https://it.mathworks.com/matlabcentral/answers/1413272-how-to-change-the-c-values-that-matches-a-3-coordinates-position-condition

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by