フィルターのクリア

Removing negative values of 3d data

5 ビュー (過去 30 日間)
Nathan Mu
Nathan Mu 2022 年 4 月 17 日
コメント済み: Tim Albertsson 2024 年 2 月 16 日
Hello, I have a diagram where I want to get rid of the lower portion (the points which have negative z value) so I can use scatteredInterpolant on it. How would I do this?
The points are stored in a 3D array with index (1,1,1) being an x-value, (1,1,2) being the corresponding y value and (1,1,3) being the corresponding z value.
Thanks!
  11 件のコメント
Torsten
Torsten 2022 年 4 月 18 日
編集済み: Torsten 2022 年 4 月 18 日
This answer should be helpful in your case:
Or you could just replace the data points with negative z by NaN - they will not appear in the plot afterwards.
Nathan Mu
Nathan Mu 2022 年 4 月 18 日
Okay thanks!

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

採用された回答

Chunru
Chunru 2022 年 4 月 18 日
編集済み: Chunru 2022 年 4 月 19 日
x = load("ggv.mat");
GGV = x.GGV;
figure
surf(GGV(:,:,2), GGV(:,:,3), GGV(:,:,1), 'EdgeColor', 'none');
xlabel('x'); ylabel('y')
figure
% to demonstrate limit works for X data (Z in the plot)
surf(GGV(:,:,2), GGV(:,:,3), max(GGV(:,:,1), -20), 'EdgeColor', 'none'); % -20 and above
xlabel('x'); ylabel('y')
% The number of points for z<0
sum(GGV(:, :, 3) < 0, 'all')
ans = 0
min(GGV(:, :, 3), [], 'all')
ans = 0
figure
% limit z data here will not make no change since no z is less than 0
surf(GGV(:,:,2), max(GGV(:,:,3), 0), GGV(:,:,1), 'EdgeColor', 'none');
xlabel('x'); ylabel('y')
figure
% limit GGV(:,:,1)
surf(GGV(:,:,2), GGV(:,:,3), max(GGV(:,:,1), 0), 'EdgeColor', 'none');
xlabel('x'); ylabel('y')
zlim([-80 20])
  3 件のコメント
Chunru
Chunru 2022 年 4 月 19 日
See above update.
Tim Albertsson
Tim Albertsson 2024 年 2 月 16 日
Hi! How did you get the GGV points from the start? I'm trying to make my own script for this and I've gotten the max lat and lon accelerations for the different speeds but not the full (GG "elipse").

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

その他の回答 (1 件)

Chunru
Chunru 2022 年 4 月 18 日
% Your data
data = randn(357, 177, 3);
% limit to 0
data(:, :, 3) = max(data(:, :, 3), 0); % to limit the surface up to 0
% You may also want to try nan (depending on how you plot the data)
idx = data(:, :, 3) < 0;
data(idx, 3) = nan;
  4 件のコメント
Nathan Mu
Nathan Mu 2022 年 4 月 18 日
I wanted to get rid of the points which have z<0 so I could use it as a function. So I would input lateral acceleration and speed and it would give out a longitudinal acceleration. However with the GGV array as is, there are two different values of long acc for any given lat acc and speed, so it isn't a function which can be put into scatteredInterpolant.
The issue may actually be due to how the array is structured. So I'll try to restructure it as a 2D matrix with three columns (x,y,z) and see how that pans out.
Chunru
Chunru 2022 年 4 月 18 日
編集済み: Chunru 2022 年 4 月 18 日
The number of points for z<0 is 0. So you cannot see any difference after limiting
sum(GGV(:, 3) < 0, 'all')

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

カテゴリ

Help Center および File ExchangeHistorical Contests についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by