calling a value in a matrix
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
sampath kumar punna
am 25 Okt. 2019
Kommentiert: galaxy
am 25 Okt. 2019
I have two sets
X Y
1 2
3 6
4 7
5 8
I have to find highest value in category Y which is 8, after finding that 8 is the highest value I have to call value 5 in category X to from a matrix [ 5 8].
I know how to find the largest value, but I don’t know how to call 5 from X category.
Please can someone help me in call the specified value.
0 Kommentare
Akzeptierte Antwort
galaxy
am 25 Okt. 2019
Let 's try
X = [1 3 4 5];
Y = [2 6 7 8];
[max_val, idx] = max(Y);
X_idx = X(idx);
7 Kommentare
galaxy
am 25 Okt. 2019
Let 's try:
find_idx = find(Y(:,2) == z(1));
for i= 2: length(z)
find_idx = vertcat(find_idx, find(Y(:,2) == z(i)));
end
out = Y(unique(find_idx), :);
you can try with other z:
example:
z= [ 9 12 18];
out =
3 9
11 12
15 18
22 12
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Licensing on Cloud Platforms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!