find elemets of matrix based on logical conditions

조회 수: 5 (최근 30일)
Hamid
Hamid 2022년 8월 1일
댓글: Hamid 2022년 8월 1일
Dear MATLAB experts,
I have a matrix and wanted to find elements that meet the condition written as goodpts. I tried find function returns a one column array. I could show want I wanted using scatter3.
Thank you in advance.
points=readtable('points.txt');
points=table2array(points);
x_p=points(:,1);
y_p=points(:,2);
z_p=points(:,3);
t_p=points(:,4);
goodpts= z_p>-5 & z_p<5 & x_p>-20 & x_p<20 & -20<y_p & y_p<20 ;
good_points=find(points(goodpts));
scatter3(x_p(goodpts),y_p(goodpts),z_p(goodpts),2,t_p(goodpts),'filled')
  댓글 수: 4
Stephen23
Stephen23 2022년 8월 1일
"In other words, record what has been shown in the scatter3 graph."
x_shown_in_graph = x_p(goodpts);
y_shown_in_graph = y_p(goodpts);
z_shown_in_graph = z_p(goodpts);
Hamid
Hamid 2022년 8월 1일
@Stephen23 Thank you so much.

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2022년 8월 1일
points=readtable('points.txt');
points=table2array(points);
x_p=points(:,1);
y_p=points(:,2);
z_p=points(:,3);
t_p=points(:,4);
goodpts= z_p>-5 & z_p<5 & x_p>-20 & x_p<20 & -20<y_p & y_p<20 ;
good_points=find(points(goodpts));
x_p_goodpts = x_p(goodpts) ;
y_p_goodpts = y_p(goodpts) ;
z_p_goodpts = z_p(goodpts) ;
t_p_goodpts = t_p(goodpts) ;
scatter3(x_p_goodpts,y_p_goodpts,z_p_goodpts,2,t_p_goodpts,'filled')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by