Question

below is the program which generates random data and converts it into 0's and 1's and saves them in .dat file in matlab every 5 minutes every time it overwrites the data with existing data how to generate different data for every 5 minutes and then save each data seperately? is it possible?

while(1)
   tic   
   A = rand(1,5)
   disp(A);
   File_id = fopen('delay.dat', 'w');
   fwrite(File_id, A, 'double'); 
   fclose(File_id);
   File_id = fopen('test.dat', 'r');
   A = fread(File_id,'double=>int8'); 
   fclose(File_id);
   disp(A);
   T=toc;
   pause(300-T)
end

No correct solution

OTHER TIPS

As Mohammad said in the comments, you should change the name of the output file in each iteration:

i = 0;
while(1)
   i=i+1;
   tic   
   A = rand(1,5)
   disp(A);
   File_id = fopen(['delay_' str(i) '.dat'], 'w');
   fwrite(File_id, A, 'double'); 
   fclose(File_id);

   File_id = fopen('test.dat', 'r');
   A = fread(File_id,'double=>int8'); 
   fclose(File_id);
   disp(A);
   T=toc;
   pause(300-T)
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top