Filter löschen
Filter löschen

How to find a row of a large matrix

2 Ansichten (letzte 30 Tage)
Pooya Zeg
Pooya Zeg am 2 Aug. 2020
Bearbeitet: Bruno Luong am 3 Aug. 2020
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])

Akzeptierte Antwort

Bruno Luong
Bruno Luong am 2 Aug. 2020
Bearbeitet: Bruno Luong am 3 Aug. 2020
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,:)

Weitere Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by