How to find a row of a large matrix

조회 수: 2 (최근 30일)
Pooya Zeg
Pooya Zeg 2020년 8월 2일
편집: Bruno Luong 2020년 8월 3일
I have a 64 by 3 matrix in which each row is a combination of 1, 2, 3, and 4. I want to find row: 1 3 3, and I used the "find" command for this, but it didn't work. Any help would be appreciated!
M = 4;
N = 3;
[X{N:-1:1}] = ndgrid(1:M);
X = reshape(cat(N+1,X{:}),[],N)
find(X==[1 3 3])

채택된 답변

Bruno Luong
Bruno Luong 2020년 8월 2일
편집: Bruno Luong 2020년 8월 3일
It seems you run old MATLAB version without auto-expansion capability.
This will work for any version:
row = find(ismember(X,[1 3 3],'rows'))
Check
X(row,:)

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by