필터 지우기
필터 지우기

transforming a matrix to an array without one values???

조회 수: 1 (최근 30일)
som
som 2011년 12월 31일
Hi all
I have a matrix having some values equal to one. I want to transform this matrix to an array without the one values.
how can I do this? for example a=[13 1 4; 45 23 1; 1 56 78] changed to b=[13 45 23 56 4 78]
cheers,

채택된 답변

Wayne King
Wayne King 2011년 12월 31일
a=[13 1 4; 45 23 1; 1 56 78];
indices = find(a==1);
a(indices) = [];
  댓글 수: 2
som
som 2011년 12월 31일
thanks for your guidance.
Matt Tearle
Matt Tearle 2011년 12월 31일
Even quicker and cleaner:
a(a==1) = [];

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by