finding the min value in a cell array

조회 수: 25 (최근 30일)
Duncan
Duncan 2014년 8월 20일
편집: DGM 2022년 7월 25일
I have the following:
cell = {[5;2;4;3;6;9] [2;5;4;8;9;7] [8;4;5;6;7;9]}
I would like to find the minimum value in the first two columns of "cell".
basically I want to take the first two columns and compute the smallest value. i.e. 2
How should I do that?

채택된 답변

Guillaume
Guillaume 2014년 8월 20일
You've not well defined what you mean by minimum (overall minimum or minimum of each column).
Overall minimum:
min(vertcat(c{[1 2]}))
minimum of each column:
cellfun(@min, c)
By the way, do not name your variable cell, this will prevent using from using the built-in cell function.
  댓글 수: 2
Duncan
Duncan 2014년 8월 20일
thank you, I meant overall minimum
DGM
DGM 2022년 7월 25일
편집: DGM 2022년 7월 25일
@Mehri Mehrnia's comment-as-answer moved here:
min(vertcat(c{[1 2]})) : it computes just for 1st array.
I look for all arrays that each array is a vector with different size.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by