Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
I want to change a variable with every iteration either randomly, how do i do that ?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I want to change a variable with every iteration either by +1 or -1 randomly and keep the overall variable in between +5 to -5
0 comentarios
Respuestas (1)
Ameer Hamza
el 22 de Oct. de 2020
Something like this will work
x = 0;
for i = 1:100
x = min(max(x + 2*(rand()>0.5)-1, -5), 5)
end
2 comentarios
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!