Table not aligning properly
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Star Strider
il 26 Feb 2024
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 Commenti
Vedere anche
Categorie
Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!