How do I store all values of a loop in a vector?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Matthew
el 12 de Abr. de 2024
Comentada: Dyuman Joshi
el 19 de Abr. de 2024
for i=1:100000;
x=randi(6)+randi(6);
end;
I am trying to find an average across all values of x and need to save them all as a vector and can't figure out how
1 comentario
Dyuman Joshi
el 19 de Abr. de 2024
An alternate method without loop -
x = randi(6,1,1e5) + randi(6,1,1e5);
Respuesta aceptada
Voss
el 12 de Abr. de 2024
x = zeros(1,100000);
for i=1:100000
x(i)=randi(6)+randi(6);
end
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!