Finding minimum value in multi dimensional cell array
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
BlkHoleSun
am 21 Okt. 2017
Bearbeitet: Stephen23
am 21 Okt. 2017
I'm going through a book trying learn this program on my own. With that said, I have a basic question to ask. I have this 5 dimensional cell array and I can not figure out how to find the minimum value in the (2,2,1:5) positions. So, If A(:,:,5) has the lowest value of 1, how can I display that 2X2 matrix? Thanks for your help!
A(:, :, 1) = { 'A' 'B' ; 'C' 5};
A(:, :, 2) = { 'E' 'F' ; 'G' 4};
A(:, :, 3) = { 'H' 'I' ; 'J' 3};
A(:, :, 4) = { 'L' 'M' ; 'N' 2};
A(:, :, 5) = { 'O' 'P' ; 'Q' 1};
0 Kommentare
Akzeptierte Antwort
Stephen23
am 21 Okt. 2017
Bearbeitet: Stephen23
am 21 Okt. 2017
Trying to perform numeric operations on a cell array is usually pointlessly complicated, so the first thing to do is to put that numeric data into a numeric array. Then your task is trivially easy:
>> V = [A{2,2,:}]
V =
5 4 3 2 1
>> [val,idx] = min(V)
val = 1
idx = 5
>> A(:,:,idx)
ans =
'O' 'P'
'Q' 1
Read this to understand how the first line of code works:
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Time Series Collections 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!