Finding minimum value in multi dimensional cell array
11 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Stephen23
on 21 Oct 2017
Edited: Stephen23
on 21 Oct 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:
More Answers (0)
See Also
Categories
Find more on Time Series Collections in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!