Fid=fopen('sfunyst.m','r');%以读的方式打开文件
allst='';
while ~feof(Fid)
FileRowStr = fgetl(Fid);%按行读取
st=strfind(FileRowStr,'%');
if ~isempty(st)
FileRowStr=blanks(0);%将含有'%'的一行置空
end
allst=strcat(allst,13,FileRowStr);%将有所行拼接为一行,并在每行后加入换行符
% allst=[allst,13,FileRowStr];
end
fclose(Fid);%关闭文件
Fid=fopen('my_sfuntmp2.m','wt');%已写的方式新建一个文件已保存处理后的s函数
fprintf(Fid,'%s\n',allst);%写入处理后的s函数
fclose(Fid);%关闭文件