How can i create dynamic file name?
显示 更早的评论
zero=0;
name=input('file name and extension: (ex: 1234.txt): ','s');
dart=importdata(name);
A=(dart.data);
new_name= sprintf('dart_%d.txt',zero);
dlmwrite(new_name,A,'delimiter',' ','newline', 'pc')
How can i generate file names like "dart_[filename]_0" ? i want to add _0 to my file names
回答(1 个)
name = input('file name and extension: (ex: 1234.txt): ','s');
[pth,name,ext] = fileparts(name);
new = sprintf('dart_%s_%d%s',name,0,ext)
and if you want to see a working example:
>> name = input('file name and extension: (ex: 1234.txt): ','s');
file name and extension: (ex: 1234.txt): test.jpeg
>> [pth,name,ext] = fileparts(name);
>> new = sprintf('dart_%s_%d%s',name,0,ext)
new =
dart_test_0.jpeg
类别
在 帮助中心 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!