Save all values of a calculation through a loop in a file
조회 수: 1 (최근 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에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!