Saving characters from a loop
显示 更早的评论
I wrote this code to count wins and losses but i need to save the W or L to a matrix.
for g=1:num_games
if scores(g,6) > scores(g,7)
disp('W')
else
disp('L')
end
end
回答(1 个)
No loop required:
V = 'LW';
Z = V(1+(scores(:,6)>scores(:,7)))
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!