Table not aligning properly
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Star Strider
el 26 de Feb. de 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 comentarios
Ver también
Categorías
Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!