Finding minimum value in multi dimensional cell array

11 次查看(过去 30 天)
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};

采纳的回答

Stephen23
Stephen23 2017-10-21
编辑:Stephen23 2017-10-21
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:

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Time Series Collections 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by