Hi!
I have a generic matrix with random numbers (-1 and +1).
M=[ 1 -1 1 -1
1 1 1 -1
-1 1 -1 1 % <----- this row
1 1 -1 1];
How can I extract a row index?
a=[-1 1 -1 1];
idx=3;
Thank you

 Akzeptierte Antwort

Rik
Rik am 21 Apr. 2020

0 Stimmen

Assuming you have that vector already:
M=[ 1 -1 1 -1
1 1 1 -1
-1 1 -1 1 % <----- this row
1 1 -1 1];
a=[-1 1 -1 1];
tmp=abs(M-a);%uses implicit expansion, works in R2016b and newer
tmp=sum(tmp,2) <= eps;
idx=find(tmp);

Weitere Antworten (0)

Kategorien

Gefragt:

am 21 Apr. 2020

Beantwortet:

Rik
am 21 Apr. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by