How to save number of arrays as different instances in a file?
1 次查看(过去 30 天)
显示 更早的评论
I have saved two arrays in a file but as a single instance. I wish to save them seperately so that I can read them separately as well. This is my code
function A= write(M)
fid=fopen('output.txt','a+');
for i = 1:size(M,1)
fprintf(fid,'%g\t',M(i,:));
fprintf(fid,'\n');
end
fclose(fid);
I have two arrays as follows.
a =
10 20 30
20 78 89
c =
1 3
4 7
6 89
10 98
I have stored them already in file. How to make them as separate instances so that when i read I can read the array I want and not just the entire file?
0 个评论
回答(1 个)
Walter Roberson
2013-12-13
In text files, there is no way to avoid reading leading information -- in your example, no way to avoid reading the text corresponding to "a" if you are interested in "c".
Binary files, on the other hand, can be "jumped around in".
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!