How to save the output of each loop in .csv file?
34 次查看(过去 30 天)
显示 更早的评论
for i = 1:20
output = myfunction(a, b, c);
Result(:,i) = output;
writematrix(output, 'Output_i.csv')
end
The 'Result' save the output as 100 rows and 20 columns,
I want to save each column of Result in a seperate .csv file. i.e., I need 20 .csv files
I have tried the following
for i = 1:20
output = Result(:,i)
writematrix(output, 'Output_i.csv')
end
Is there any way either with in the loop or after obtaing result for each loop to save the oputput of each iteration of loop?
Thanks
0 个评论
采纳的回答
更多回答(1 个)
Arif Hoq
2022-12-7
if your "result " is in matrix form, then try this
result=randi(100,100,20);
% making text files
for j=1:size(result,2)
col= result(:,j);
writematrix(col,[num2str(j) '.txt'])
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!