Save all values of a calculation through a loop in a file
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
V=[31:1:61];
angle=2;
for V=(31:1:61)
save myresults UVW0 -mat
end
Hello,
I need your help please!
I want to save all the results for UVW0 in a file bu my current program only saves the last results of the calculation in the mat file.
How can I save all the results for each calculation in the mat file?
Many thanks in advance!
0 comentarios
Respuesta aceptada
Stephen23
el 22 de Feb. de 2023
Editada: Stephen23
el 22 de Feb. de 2023
"How can I save all the results for each calculation in the mat file?"
The standard, efficient, simple approach is to store the data in one array and save it once after the loop.
But why do you need a loop anyway? That calculation is easy to perform without a loop:
V = 31:1:61; % got rid of the superfluous square brackets too
angle = 2;
UVW0 = V .* [cos(angle);0;sin(angle)]
save myresults.mat UVW0
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical 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!