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!