mercredi 25 février 2015

Exporting loop variables to excel (too may files error)

17 variables to export in a loop i=3632. When running the script for a small loop i=3, it works perfectly. However, when extending the script to 17 variables and i=3632, it stops at i=16 giving this message :


"??? C:\ProgramFiles\MATLAB\R2010a\toolbox\matlab\codetools\openvar.m: Too many files open; check that FILES = 20 in your CONFIG.SYS file."


I have exported each variable (17 in total) to an individual spreadsheet. It may be possible to do it in the same spreadsheet, divided in 17 sheets (one per each), but I do not know how to proceed.


Could you help me on solving this issue please? Thank you very much in advance!


My code at this moment:



% Set number of loops and matrixsize
nloops = length(a1);
matrixsize=[19 19];

% Preallocate output matrix
nrows_output=nloops*matrixsize(1);
outputNDVI =zeros(nrows_output,matrixsize(2));
outputfAPAR =zeros(nrows_output,matrixsize(2));
% I have written 17 different output variables (just wrote 2 of them as an example)

for i = 1:nloops
row_start = ((i-1) * matrixsize(1)) + 1;
row_end = i * matrixsize(1);

% Do some calculations
NDVI_T = i*ones(matrixsize);
fAPAR = i*ones(matrixsize)*2;
outputNDVI(row_start:row_end,:) =NDVI_T;
outputfAPAR(row_start:row_end,:)=fAPAR;
% I have written 17 different outputvariable (just wrote 2 of them as an example)
end

xlswrite('NDVI.xlsx', outputNDVI);
xlswrite('fAPAR.xlsx', outputfAPAR);
% I have written 17 different xlswrite (just wrote 2 of them as an example)

Aucun commentaire:

Enregistrer un commentaire