How to use max function in cell arrays or structures?

I have a cell arrays:
.
.
how do i apply the
max function
to get the maximum 7x2 matrix value across all 3 matrices?
Example
g{1,1} = 1 2 3
2 4 5
5 3 2
g{1,2} = 2 4 1
1 7 2
1 1 2
g{1,3} = 2 2 2
3 1 2
4 8 1
So i will bring the the highest matrix such that
A = 2 4 3
3 7 5
5 8 2

 채택된 답변

Jan
Jan 2014년 11월 2일
g{1,1} = [1 2 3
2 4 5
5 3 2]
g{1,2} =[ 2 4 1
1 7 2
1 1 2]
g{1,3} =[ 2 2 2
3 1 2
4 8 1]
result = max(cat(3, g{:}), [], 3)

댓글 수: 1

hi.
will appreciate if you could explain?
what does the (3, g{:]), [], 3 means?
thanks

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

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 11월 2일
v={rand(7,2),rand(7,2),rand(7,2)}
a=cell2mat(v)
out=max(a(:))

댓글 수: 4

currently is only 3 cells. but i may have another cell arrays that may have 100+ cells.
does that mean i have to put
rand(7,2)
100 times?
or is there a function i can do this?
Thanks for you help!
No, it was just an example, if v is your cell array just write
a=cell2mat(v)
out=max(a(:))
opps
i mean not only bringing out the highest value. but the highest 7x2 matrix.
g{1,1} = 1 2 3
2 4 5
5 3 2
g{1,2} = 2 4 1
1 7 2
1 1 2
g{1,3} = 2 2 2
3 1 2
4 8 1
So i will bring the the highest matrix such that
A = 2 4 3
3 7 5
5 8 2
g{1,1} = [1 2 3
2 4 5
5 3 2]
g{1,2} =[ 2 4 1
1 7 2
1 1 2]
g{1,3} =[ 2 2 2
3 1 2
4 8 1]
out=max(reshape(cell2mat(g),3,3,[]),[],3)

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

카테고리

도움말 센터File Exchange에서 Data Types에 대해 자세히 알아보기

태그

질문:

2014년 11월 2일

댓글:

2014년 11월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by