Azzera filtri
Azzera filtri

Set points that matches with a vector as NaN

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

Dave B
Dave B il 12 Ago 2021
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 Commenti
Philippe Corner
Philippe Corner il 12 Ago 2021
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 il 17 Ago 2021
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

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by