selecting values from matrix

1 Ansicht (letzte 30 Tage)
Hamid
Hamid am 23 Nov. 2015
Kommentiert: Star Strider am 23 Nov. 2015
Hi everyones,
I explain my question with an example :
q2 is obtained from an equation
A=[r1 r2 r3;q1 q2 q3;k1 k2 k3];
I want to select proportional row values (r2 and k2).
what should I do?
Thanks.

Akzeptierte Antwort

Star Strider
Star Strider am 23 Nov. 2015
Another way, especially if you don’t know where ‘r2’ is in the matrix, regardless of how large the matrix is:
A = [1:3; 4:6; 7:9];
r2 = 5;
[r,c] = find(A == r2);
other_values = setdiff([1:size(A,1)],r);
Result = A(other_values,c)
Result =
2
8
  4 Kommentare
Hamid
Hamid am 23 Nov. 2015
OK Thanks very much
Star Strider
Star Strider am 23 Nov. 2015
My pleasure.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

the cyclist
the cyclist am 23 Nov. 2015
Here's one way:
idx = A(2,:)==q2;
values = A([1 3],idx);
  3 Kommentare
the cyclist
the cyclist am 23 Nov. 2015
Maybe Star Strider's answer works for you? If not, then I would say you should start over with a new question, and fully specify the general problem.
Hamid
Hamid am 23 Nov. 2015
OK thanks

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots 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