max row vector in matrix

2 次查看(过去 30 天)
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
>>

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Geometric 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