How to Find value inside a matrix that satisfies a condition and store that value in column 1 its corresponding row in column 2 and its column in column 3
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Rohit P
am 18 Okt. 2021
Kommentiert: Mathieu NOE
am 25 Okt. 2021
Hello All,
i have a random 5*5 matrix.now i want to check in the matrix which value is present between 0.25 and 0.50.if present,put that value in column 1,its corresponding row number in column2 and its corresponding column 3 of another matrix ''Myvalues"?.how can i do that?.
Any kind of help will be appreciated.Thank you in advance
0 Kommentare
Akzeptierte Antwort
Mathieu NOE
am 18 Okt. 2021
hello
sounds bit like a homework..?
here your are :
A = rand(5,5)
[r,c] = find(A>=0.25 & A <= 0.5);
for ci = 1:numel(r)
val = A(r(ci),c(ci));
out(ci,1) = val; % value
out(ci,2) = r(ci); % row
out(ci,3) = c(ci); % column
end
out
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!