フィルターのクリア

Function Max for Cell

1 回表示 (過去 30 日間)
baby
baby 2012 年 10 月 17 日
How to use function max for cell?
Before I used max(b), but I am getting error and i use ([b{:}]) it looks like sum
this's my code
a= input ('Number of Participant :');
for c = 1:a
str1 = ['What''s the name (',num2str(c),') :'];
str2 = ['What''s his/her value (',num2str(c),') :'];
b{c,1} = input(str1,'s');
b{c,2} = input(str2);
end
disp(b)
[m,n]= size (b);
Mb=max([b{:}])
when i try that code above, i think the result is total of value
i dont want total of value, i just want max of the value
anybody know?
please help me :)
  1 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 10 月 17 日
編集済み: Azzi Abdelmalek 2012 年 10 月 17 日
Mb=max([b{:}]) is correct
or
Mb=max(b{:})

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

採用された回答

Kye Taylor
Kye Taylor 2012 年 10 月 17 日
編集済み: Kye Taylor 2012 年 10 月 17 日
Try
Mb = max([b{:,2}]);
  1 件のコメント
baby
baby 2012 年 10 月 17 日
when i try to input a data, it just give the result "one value"
example :
___________________________________
the number of participant : 2
what's the name : juni
what's his/her value of first test : 90
what's his/her value of second test : 80
what's the name : andy
what's his/her value of first test : 75
what's his/her value of second test : 75
___________________________________
when i see the result, it just show one value
the result is just show Mb = 90 not Mb = 90 80
how to show all value of one participant if his/her value is the highest?

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

その他の回答 (1 件)

Doug Hull
Doug Hull 2012 年 10 月 17 日
Why are you storing the results in a cell array? Also, using input command is going to be very frustrating for users. There must be a better way f getting input, like edit a text file?
If you insist though:
c{1,2} = 11;
c{2,2} = 22;
c{3,2} = 33;
[c{:,2}]'

カテゴリ

Help Center および File ExchangePerformance and Memory についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by