フィルターのクリア

max row vector in matrix

2 ビュー (過去 30 日間)
Faisal Al-Wazir
Faisal Al-Wazir 2022 年 1 月 28 日
コメント済み: Faisal Al-Wazir 2022 年 1 月 29 日
I'm doing a code to calculate marks for teams and to display them as a table after that i want to display the winner by getting the maximum marks (which is a row vecter in a matrix)
n=input('how many teams: ') ;
S = struct ;
if n>0
for i=1:n
S(i).Team = input(['team "' num2str(i) '" name : '] , 's');
a = input(['team "' num2str(S(i).Team) '" 1st throw: ']);
b = input(['team "' num2str(S(i).Team) '" 2nd throw : ']);
c = input(['team "' num2str(S(i).Team) '" 3rd throw : ']);
d = input(['team "' num2str(S(i).Team) '" 4th throw : ']);
e = input(['team "' num2str(S(i).Team) '" 5th throw : ']);
S(i).Marks = [a b c d e];
S
r=1:n;
end
A=struct2table(S)
c=A(:,2);
w=table2array(c);
else
disp("no teams")
end

採用された回答

Benjamin Thompson
Benjamin Thompson 2022 年 1 月 28 日
A =
3×2 table
Team Marks
___________ _________________________
{'Cubs' } 4 12 6 7 9
{'Reds' } 7 4 2 7 3
{'Yankees'} 5 9 3 6 8
>> w
w =
4 12 6 7 9
7 4 2 7 3
5 9 3 6 8
>> max(w)
ans =
7 12 6 7 9
>>
  2 件のコメント
Faisal Al-Wazir
Faisal Al-Wazir 2022 年 1 月 29 日
yes you can see it's wrong
Faisal Al-Wazir
Faisal Al-Wazir 2022 年 1 月 29 日
it should be 4 12 6 7 9

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGeometric Transformation and Image Registration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by