How to save number of arrays as different instances in a file?

1 vue (au cours des 30 derniers jours)
Ravi Teja
Ravi Teja le 13 Déc 2013
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?

Réponses (1)

Walter Roberson
Walter Roberson le 13 Déc 2013
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".

Catégories

En savoir plus sur Cell Arrays dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by