Create a data and save a filename automatically
古いコメントを表示
I have a function in matlab.For ex,
%function [mean std]=size(data,channel)
i set data's filename=ET1_A(imported to workspace alrdy) and channel=2 (total no.channel=63), to find the mean and std of selected data(ET1_A),and I want to save the statistical feature into .mat form in the workspace as shown in below:
%savefile='ET1_A_stat.mat'; save(savefile,'mean','std')
However,if i choose another data like ET1_B,I need to change my code manually like: %savefile='ET1_B_stat.mat'; save(savefile,'mean','std')
Is there any good idea of using MATLAB's efficient code to change the filename automatically nicely?
Thanks
1 件のコメント
Image Analyst
2012 年 11 月 23 日
Don't use size() for the name of your function or you'll blow away the built in size() function.
回答 (1 件)
Walter Roberson
2012 年 11 月 23 日
0 投票
6 件のコメント
YEE
2012 年 11 月 23 日
Walter Roberson
2012 年 11 月 23 日
The techniques used there to construct the file names can be used to construct file names for saving files.
savefile = [filename '_stat.mat'];
save(savefile, 'mean', 'std');
YEE
2012 年 11 月 23 日
Ilham Hardy
2012 年 11 月 23 日
savefile=sprintf('%s_Channel%d.mat',data,channel);
% savefilename='savefile.mat'
% save(savefilename)
save(savefile)
Walter Roberson
2012 年 11 月 23 日
DO you have a variable which would have the string 'ET1_A_I1' stored in it at that point? If you are loading files in a loop, then how did you figure out which file to load?
カテゴリ
ヘルプ センター および File Exchange で File Operations についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!