原文地址:matlab中添加路径及save 、load文件方法 作者:海阔天空
1 、添加存储路径:
workpath = strcat(filesep,\'tmp\',filesep,\'example_\',datestr(now,\'yymmdd\'),\'_\',datestr(now,\'HHMM\')); if (~isunix)
workpath =
strcat(\'.\',workpath);
end
if (exist(workpath))
error(\'The working dir already
exist\');
else
mkdir(workpath);
end
SIM_DIR = workpath;
2、创建存储目录:
filename = strcat(\'D:存储文件夹名example.txt\');
fid = fopen(filename,\'at\');
fprint(fid,\'Length = %d BER = %fn\',BER
,SNR);
fprint(fid,\'SNR Rotn\');
fclose(fid);
...
fid = fopen(filename,\'at\');
fprint(fid,\'%f %fn\',SNR,Rot);
fclose(fid);
3、save和load的使用方法:
save(strcat(\'D:存储文件夹名\',filesep,\'example\',\'.mat\'),\'data\');
load(strcat(\'D:存储文件夹名\',filesep,\'example\',\'.mat\'));
4、批量存储.mat文件命名方法:
tempPe = Pe*100;
storageName = strcat(\'result_\',\'Pe_\',num2str(tempPe),\'.mat\');
save(storageName,\'SNR\',\'BER\');
workpath = strcat(filesep,\'tmp\',filesep,\'example_\',datestr(now,\'yymmdd\'),\'_\',datestr(now,\'HHMM\')); if (~isunix)
end
if (exist(workpath))
else
end
SIM_DIR = workpath;
2、创建存储目录:
filename = strcat(\'D:存储文件夹名example.txt\');
fid = fopen(filename,\'at\');
fprint(fid,\'Length = %d
fprint(fid,\'SNR Rotn\');
fclose(fid);
...
fid = fopen(filename,\'at\');
fprint(fid,\'%f %fn\',SNR,Rot);
fclose(fid);
3、save和load的使用方法:
save(strcat(\'D:存储文件夹名\',filesep,\'example\',\'.mat\'),\'data\');
load(strcat(\'D:存储文件夹名\',filesep,\'example\',\'.mat\'));
4、批量存储.mat文件命名方法:
tempPe = Pe*100;
storageName = strcat(\'result_\',\'Pe_\',num2str(tempPe),\'.mat\');
save(storageName,\'SNR\',\'BER\');