필터 지우기
필터 지우기

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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by