Take minimum and maximum of columns for a 1x31 cell

1 回表示 (過去 30 日間)
Katherine
Katherine 2014 年 1 月 7 日
編集済み: per isakson 2014 年 1 月 7 日
I have a cell array psdMonth that is 1x31, with each cell a 1x114 int 32. I would like to take the minimum of all of the columns of each cell to get a composite minimum that would be 1x114 int 32. So I would want the minimum of psdMonth{1}(1)......psdMonth{31}(1), and then the minimum of psdMonth{1}(2)....pdMonth{31}(2), etc.
I had tried something like this:
minpsdMonth = min(cat(1,psdMonth{:}))
which does create a 1x114 int32, but I'm not sure how to test if it's actually doing what I think it should. Can anyone tell me how I would get the output I want? Or verify that what I am doing is correct?
Thanks!

採用された回答

per isakson
per isakson 2014 年 1 月 7 日
編集済み: per isakson 2014 年 1 月 7 日
Two comments
  • your solution looks ok to me
  • test with some synthetic data, the results of which you know
  3 件のコメント
Katherine
Katherine 2014 年 1 月 7 日
Thanks for the simple advice. Sometimes when you're beating your head against the wall about something it's good to be reminded.
per isakson
per isakson 2014 年 1 月 7 日
編集済み: per isakson 2014 年 1 月 7 日
"integers or only doubles" Here, I trust Matlab. If it doesn't issue an error it should be ok.
A little test
>> c={int32([10 35 45 55 67]),int32([45 55 65 76 86]),int32([55 58 59 90 1])};
>> min(cat(1,c{:}))
ans =
10 35 45 55 1

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by