Save file with different extension
13 次查看(过去 30 天)
显示 更早的评论
Hi,
I am a newbie and am opening some files, adding some lines, then saving the files. I can't figure out how to save each file I open with a new extension while keeping the filename the same.
Here is how I am opening the files:
DefaultFile='';
[FileName,PathName] = uigetfile('*.*','Select File to Plot',DefaultFile); %choose file to open.
%%%%**************** Read the File *************
fid=fopen(fullfile(PathName,FileName));
To save the file do I use the following fopen and if so what do I put where the question marks are?
fileID = fopen(??????,'w');
Thanks
0 个评论
采纳的回答
Image Analyst
2012-12-11
You have another fopen() to open an output file. Your question marks should be replaced by the full file name of your output file. You can use sprintf() (if needed) and fullfile() to create that output file name. Then use fprintf to write text to it. Then call fclose() to close the two files.
7 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Low-Level File I/O 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!