Instead of that double for loop with teams:teams:
for r = teams:teams
row = [];
for c = teams:teams
names = input('Enter team names in : ', 's') ;
row = [row,names];
end
M1 = [M1, row];
end
have only this
names = input('Enter team names (separated by spaces) : ', 's') ;
teamNames = strsplit(names, ' ')
If the team names are just one word with spaces between words, this will put every team name into a cell array variable called teamNames where eash cell in that array is a character array with the name of one team.
Best Answer