MATLAB: To extract the random integer into a file

extract data

HEllo guys,
am new to this matlab, my Q is probably very simple for you guys.please help me. I want to extract the random integer from the script
data = randint(1,48,2) to a new file so that the same data can be called for and use for the next iteration. someone can help me please.

Best Answer

If you get a little confused with fread and fwrite, then
you can try another command fprintf n fscanf
Here I give you sample code :
Let say you want to store 'data = randint(1,48,2)' into txt file.
data = randint(1,48,2)
fid = fopen('data01.txt', 'w');
fprintf(fid,'%d ',data);
fclose(fid);
And for recalling this data later, you can read from the text file you have created
fid = fopen('data01.txt');
m5 = fscanf(fid,'%d')'
fclose(fid);
Ask me again if it still difficult to understand.