フィルターのクリア

Adding a title to save file that is dynamic

2 ビュー (過去 30 日間)
Theodore
Theodore 2013 年 7 月 30 日
Hello. I was wondering for saving images or writing xls files if there was a way to add additional wording in the title for dynamic names. For example I have:
b = csvread(source_files(j).name);
savecsv= source_files(j).name;
And when writing an image/csv I can get it to reproduce whatever the file is named after the run, but I want to add to the end of the file name so for example
b = csvread(source_files(j).name);
savecsv= source_files(j).name;
biggarr=[date minmaxmean];
[status,message] = xlswrite(savecsv,biggarr);
Will give me Antelope Lake.xls for the first run. Is there a way to make it so that when I save different arrays of information I have different names. For example:
Run 1: Antelope Lakemaxtemp.xls Antelope Lakemintemp.xls
Run 2: Ruby Lakemaxtemp.xls Ruby Lakemintemp.xls
I basically just want to add on to the dynamically changing file name so that I have different files for specific variable/arrays. Thanks!

採用された回答

dpb
dpb 2013 年 7 月 30 日
編集済み: dpb 2013 年 7 月 31 日
Sure, just build a new filename instead of reusing the old one...use pieces of the old if desired, of course. You just have to have some way to decide what the new piece(s) are to be. Here I just stored them as an array internally; you may want something more clever...knock your socks off in that regard. :)
stuff={'maxtemp';'mintemp'}; % the new pieces for file names
...
for i=1:length(sourcefiles)
...
[p,n,e]=fileparts(sourcefiles(1).name); % path,name,extension
% do what to get max temp's and ready to write
outname=strcat(n, stuff(1), e);
xlswrite(outname,biggarr);
% now get min temp's and ready to write
outname=strcat(n, stuff(2), e);
xlswrite(outname,biggarr);
...
This will duplicate your sample cases above for each pass thru the loop on multiple files.
As always, "salt to suit..." :)
  1 件のコメント
Theodore
Theodore 2013 年 8 月 6 日
Thanks dpb! I appreciate the help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by