removing some data in a 4d plot

조회 수: 1 (최근 30일)
Hamid Basiri
Hamid Basiri 2022년 5월 12일
답변: Chunru 2022년 5월 12일
Hi every one,
I have a 4d plot and want to make some limitation for the 4th dimention of my graph. For example if the value is higher than 0.9 plot otherwise ignore that point. I am using scatter3(x,y,z,10,teta,'filled') and I attached the sample input file.
I did the limitation using teta(teta>0.9)=[];
And the error I faced is:
Error using scatter3
Color must be one RGB triplet, an m-by-3 matrix of RGB triplets with one color per scatter point, or an m-by-1 vector with one value
per scatter point.
cla
load 4dplot.txt
x = 4dplot(:,1);
y = 4dplot(:,2);
z = 4dplot(:,3);
teta = 4dplot(:,4);
scatter3(x,y,z,10,teta,'filled')
ax = gca;
ax.XDir = 'reverse';
view(-31,14)
cb = colorbar;

채택된 답변

DGM
DGM 2022년 5월 12일
You have to apply the same operation to all of the vectors.
load 4dplot.txt
x = X4dplot(:,1);
y = X4dplot(:,2);
z = X4dplot(:,3);
teta = X4dplot(:,4);
goodpts = teta <= 0.9;
scatter3(x(goodpts),y(goodpts),z(goodpts),10,teta(goodpts),'filled')
ax = gca;
ax.XDir = 'reverse';
view(-31,14)
cb = colorbar;

추가 답변 (1개)

Chunru
Chunru 2022년 5월 12일
data = load('4dplot.txt');
% x = 4dplot(:,1); % wrong: variable names canno start with number
x = data(:,1);
y = data(:,2);
z = data(:,3);
teta = data(:,4);
idx = teta >= 0.9;
scatter3(x(idx),y(idx),z(idx),10,teta(idx),'filled')
ax = gca;
ax.XDir = 'reverse';
view(-31,14)
cb = colorbar;

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by