필터 지우기
필터 지우기

Quick Question! Get the Index

조회 수: 2 (최근 30일)
Xiao Tang
Xiao Tang 2012년 8월 11일
Hi guys, I have a matrix A,
A = [1;1;0;1;1;1;0]
As you can see, A(3) =0;A(7) = 0;
Is there any function or logical index I can use to get[3;7]?
Thanks!

채택된 답변

Matt Fig
Matt Fig 2012년 8월 11일
편집: Matt Fig 2012년 8월 11일
idx = find(~A)
or
idx = find(A~=0)
or
idx = find(A==0)
or (this might be much faster if you are doing this in a FOR loop)
I = 1:length(A); % Define outside loop
idx = I(A==0) % If A is changing every iteration, but not numel.
% or I(~A), etc.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by