Save all values of a calculation through a loop in a file
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Stephen23
2023-2-22
编辑:Stephen23
2023-2-22
"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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!