Hello,
I have written output (numeric only) to a text file as follows:
fmt2=['%8s' '%4.f%4.f%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d\n'];
sav_fid2 = fopen('Names2.txt', 'wt');
for jkl = 1:cnf
fprintf(sav_fid2,fmt2, 'stage_1.txt', xy(jkl,:),sum(data(ROI1,jkl+1)),sum(data(ROI2,jkl+1)),sum(data(ROI3,jkl+1)),sum(data(ROI4,jkl+1)),sum(data(ROI5,jkl+1)),sum(data(ROI6,jkl+1)),sum(data(ROI7,jkl+1)),sum(data(ROI8,jkl+1)),sum(data(ROI9,jkl+1)),sum(data(ROI10,jkl+1)),sum(data(ROI11,jkl+1)),sum(data(ROI12,jkl+1)),sum(data(ROI13,jkl+1)),sum(data(ROI14,jkl+1)),sum(data(1:end,jkl+1)));
end
fclose(sav_fid2);
Now, I need to read in those numbers (as a matrix), multiply them by 256 and then print the matrix (after multiplication) to a different text file. I tried this:
clear
clc
fmt2=['%8s' '%4.f%4.f%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d%8d\n'];
fid = fopen(''stage_1.txt'', 'wt');
num_t = fscanf(fid, fmt2);
fclose(fid);
I am getting:
num_t =
''
Is there a mistake with the format used to read the pattern with fscanf? Is fscanf the most appropriate way to read in these numbers?
* the number 256 will change from file to file. I can handle that part of the code. For the purposes of this example, we can assume that 256 is a constant.
