How to find index of cell array

I have a cell array of
A = [2] [4] [5] [7]
[3] [10] [1] [9]
its index is given by code
[maxval idx] = max([imp{:}])
Above code is giving
maxval = 10
index = 4
whereas I want result as index = 6 (row wise calculation)
Please help

3 comentarios

Stephen23
Stephen23 el 24 de En. de 2017
Editada: Stephen23 el 24 de En. de 2017
MATLAB works along columns first. This confuses some beginners.
Also note that most of your previous twenty questions would have been trivial if you stopped pointlessly storing your data in a cell array, and simply stored it in a numeric array:
M = cell2mat(A);
Better, simpler, faster, easier to understand.
Vishal Sharma
Vishal Sharma el 24 de En. de 2017
It's not working. Error shown is Error in ==> cell2mat at 84 m = cat(1,m{:});
the cyclist
the cyclist el 24 de En. de 2017
Vishal, perhaps more to the point is that you are asking many extremely basic questions, but not understanding the "big picture" of how the answers relate to each other.
You will be better off learning the fundamentals of MATLAB. There are many free resources for that. For example, you could start here.
If you do not learn the fundamentals, you will forever be reliant on this forum for every tiny question.

Iniciar sesión para comentar.

 Respuesta aceptada

Takuji Fukumoto
Takuji Fukumoto el 25 de En. de 2017
How about using transposition?
B=A';
[maxval idx] = max([B{:}])
You can get
maxval =
10
idx =
6

Más respuestas (0)

Categorías

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by