Finding minimum value in multi dimensional cell array

5 visualizaciones (últimos 30 días)
BlkHoleSun
BlkHoleSun el 21 de Oct. de 2017
Editada: Stephen23 el 21 de Oct. de 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};

Respuesta aceptada

Stephen23
Stephen23 el 21 de Oct. de 2017
Editada: Stephen23 el 21 de Oct. de 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:
  1 comentario
BlkHoleSun
BlkHoleSun el 21 de Oct. de 2017
very helpful! Bracket location is where I was going wrong. Thanks for your instruction.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by