Table not aligning properly
7 ビュー (過去 30 日間)
古いコメントを表示
ThePriceisRightWheel()
function ThePriceisRightWheel()
clc
clear
RunTotal = 100000;
Contestant1Spins = 5:5:100;
SpinNumber = numel(Contestant1Spins);
Wins = [];
for Trial1= 1:SpinNumber
Spin1 = Contestant1Spins(Trial1);
count = 0;
for Trial2 = 1:RunTotal
Spin2 = randi([0, 100]);
if Spin2 > Spin1
continue
elseif Spin1 == Spin2
Spin3 = randi([0,100]);
if Spin3 > Spin1
continue
end
end
count = count + 1;
end
TotalWins(Trial1) = count;
end
Probability = TotalWins/ RunTotal;
disp('Contestant 1 Spin vs. Probability of Winning');
disp([Contestant1Spins' Probability']);
end
I have this code to simulate a wheel from the Price is right, but I need a table that displays "Contestant 1 Spin vs. Probability of Winning", but the actual numbers do not line up properly underneath my header. If anyone could let me know how to fix this I would appreciate it.
0 件のコメント
回答 (1 件)
Star Strider
2024 年 2 月 26 日
ThePriceisRightWheel
function ThePriceisRightWheel()
clc
clear
RunTotal = 100000;
Contestant1Spins = 5:5:100;
SpinNumber = numel(Contestant1Spins);
Wins = [];
for Trial1= 1:SpinNumber
Spin1 = Contestant1Spins(Trial1);
count = 0;
for Trial2 = 1:RunTotal
Spin2 = randi([0, 100]);
if Spin2 > Spin1
continue
elseif Spin1 == Spin2
Spin3 = randi([0,100]);
if Spin3 > Spin1
continue
end
end
count = count + 1;
end
TotalWins(Trial1) = count;
end
Probability = TotalWins/ RunTotal;
fprintf('Contestant 1 Spin vs. Probability of Winning\n')
fprintf('\t%3d\t\t\t%.4f\n',[Contestant1Spins' Probability'].');
end
.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Develop Apps Using App Designer についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!