Select specific cells from a cell array and create a seperate vector

조회 수: 3 (최근 30일)
Hi everyone,
I have the following cell array
Max_Col_Cell(9,10,15)
I want to isolate every combination of the first two elements (9,10) for all the 15 values of the third element and create new vectors having one column with 15 rows.
For example create a vector having (1,1,:). Another vector having (2,1,:) etc....
I am trying to write a for loop but its not working.
How can i do this?
Ilias
  댓글 수: 2
Ameer Hamza
Ameer Hamza 2020년 3월 28일
Why do you want to create seperate vectors each set of 15 elements. See here why it is a bad ideahttps://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer. Using a matrix is much better solution.
Ilias Minas
Ilias Minas 2020년 3월 28일
Thank for your reply.
I thought that having seperate vactors it would be easier to handle them cause i want to extract the maximum value of those 15 elements.
Is it possible to rearrange in the way that i want in a matrix?

댓글을 달려면 로그인하십시오.

채택된 답변

the cyclist
the cyclist 2020년 3월 28일
편집: the cyclist 2020년 3월 28일
Does your cell array have only numeric values in it?
If yes, then
maxVal = max(cell2num(C),[],3)
where C is your cell array.
  댓글 수: 3
Ameer Hamza
Ameer Hamza 2020년 3월 28일
I guess the cyclist wanted to write
maxVal = max(cell2mat(C),[],3)
the cyclist
the cyclist 2020년 3월 28일
Sorry, yes, cell2mat. (I also have cell2num from the File Exchange.)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by