Why won't this display?
Mostrar comentarios más antiguos
I am trying to display a random number x. I have tried the following for making the code display x but without success:
a = 16807;
b = 2147483647;
function [x] = lrng(m,a)
x(1)= (m-1)*rand(1)+1
for k=2:10
x(k)=mod(a*x(k-1),m);
end
fprintf('%.2f', x)
end
and
a = 16807;
b = 2147483647;
function [x] = lrng(m,a)
x(1)= (m-1)*rand(1)+1
for k=2:10
x(k)=mod(a*x(k-1),m);
end
disp(x)
end
Every time I try, I get the confirmation that the code has been run, but then it wont show me the output. What do I do? Have I made some mistakes regarding the code or is it something else?
Kind regards Jens
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!