For example, I've got cell array:
c = {[10 12 13]' [4 5 6]' [7 8 9]';...
[10 20 30]' [40 5 60]' [70 80 90]';...
[100 200 300]' [400 500 600]' [3 800 9]' }
I need to find min in every row of c{i,j}, where i=j. So, I need to take c{1,1}, c{2,2}, c{3,3} and to find min of every row. I dont think my description is clear, so see the attached file. So the answer must be
ans = [3 5 9]'
Thanks a lot !

 採用された回答

Andrei Bobrov
Andrei Bobrov 2015 年 3 月 13 日
編集済み: Andrei Bobrov 2015 年 3 月 13 日

0 投票

k = c(1:size(c,1)+1:end));% EDIT (diag(c));
or
k = c(eye(size(c))>0);
out = min([k{:}],[],2);

6 件のコメント

Nik Zakh
Nik Zakh 2015 年 3 月 13 日
Undefined function 'diag' for input arguments of type 'cell'
Andrei Bobrov
Andrei Bobrov 2015 年 3 月 13 日
編集済み: Andrei Bobrov 2015 年 3 月 13 日
Sorry, I now use Octave... fixed.
Nik Zakh
Nik Zakh 2015 年 3 月 13 日
It works ! Thanks ! Now I need to understand HOW does it work :)
Nik Zakh
Nik Zakh 2015 年 3 月 22 日
Thanks for the previous answer ! Can you now help me to do the same thing, but for the case when i~=j ? Thanks !
Andrei Bobrov
Andrei Bobrov 2015 年 3 月 23 日
variant
k = c(~eye(size(c)));
out = min([k{:}],[],2);
Nik Zakh
Nik Zakh 2015 年 3 月 23 日
That's easy ! Thank you one more time !

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

その他の回答 (1 件)

Jos (10584)
Jos (10584) 2015 年 3 月 23 日

0 投票

min(cat(2,c{1:size(c,1)+1:end}),[],2)

カテゴリ

ヘルプ センター および File ExchangePolynomials についてさらに検索

タグ

質問済み:

2015 年 3 月 13 日

回答済み:

2015 年 3 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by