Loop on changing databases
3 ビュー (過去 30 日間)
表示 古いコメント
Hi,
We run a code where part of it depends on variables we import from excel.
We want to run a loop on the code for it to run 20 times importing the variable from different excel files to create scenarios. Each scenario has to be saved automatically. The name of the variables never change.
Can we do this?
Thank you very much
0 件のコメント
回答 (1 件)
Abhiram Bhanuprakash
2015 年 7 月 6 日
Hi Alexandra,
Yes you can do this using xlsread to read from different Excel files. The structure of the code would look like this:
excelFilenamesCellArray = {Array of Excel file names/paths as strings};
for i=1:20
[num,txt,raw] = xlsread(excelFilenamesCellArray{i});
%Create scenario
%Save as separate file using (may be) xlswrite?
xlswrite(filename,<scenario_variable>);
end
I'm not sure what you mean by 'scenario', so the above code is not complete. You can modify it as per your requirement.
Doc for xlsread and xlswrite are at:
Hope this helps,
Cheers!
Abhiram
参考
カテゴリ
Find more on Data Import from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!