Saving matrices to a text file
1 次查看(过去 30 天)
显示 更早的评论
I have the following part of code;
for m=1:4
for n=1:4
%E_k_all(element_no,m,n)=k(m,n);
E_k_g_all(element_no,m,n)=k_g(m,n);
E_m_all(element_no,m,n)=mass(m,n);
end
end
Now, I want to save the matrix e_k_g_all for each element into a text file (or even a .m file).
I want the saved matrix format to be same as that in matlab. How to do it?
0 个评论
回答(1 个)
Geoff Hayes
2015-9-7
kajalschropa - why not use save and save the matrix to a mat file after the code has finished iterating? Something like
for m=1:4
for n=1:4
E_k_g_all(element_no,m,n)=k_g(m,n);
E_m_all(element_no,m,n)=mass(m,n);
end
end
save('myMatFile.mat', 'E_k_g_all');
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!