Creating file names for save command
1 次查看(过去 30 天)
显示 更早的评论
I have the following code:
file_dir = 'C:\Users\mydir';
datestamp=string(datetime('now','TimeZone','local','Format','yyyyMMdd_HHmmss'));
file_name=strcat(file_dir,'sps_',datestamp,'.mat');
save(file_name);
which returns the following error:
Error using save
Argument must contain a character vector.
Not sure how to fix this?
2 个评论
Nagabhushan SN
2018-8-25
Same error:
save('temp.mat', data);
Error using save
Must be a string scalar or character vector.
回答(2 个)
KSSV
2016-10-6
编辑:KSSV
2016-10-6
You have to put some data in the file....
file_dir = pwd;
datestamp=string(datetime('now','TimeZone','local','Format','yyyyMMdd_HHmmss'));
file_name=strcat(file_dir,filesep,'sps_',datestamp,'.mat');
data = rand(10,10) ;
save(file_name,'data');
5 个评论
KSSV
2016-10-6
How about replacing:
file_name=strcat(file_dir,filesep,'sps_',datestamp,'.mat');
with
file_name=char(strcat(file_dir,filesep,'sps_',datestamp,'.mat'));
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 JSON Format 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!