How to change code in scripts using command
14 次查看(过去 30 天)
显示 更早的评论
Certainly ,i could change it manually.But using command along with Conditional statements can achieve this process automatically.
0 个评论
采纳的回答
Azzi Abdelmalek
2016-4-30
编辑:Azzi Abdelmalek
2016-4-30
You can read the content of your m-file
fid=fopen('file.m')
line=fgetl(fid);
k=1;
while ischar(line)
out{k,1}=line;
line=fgetl(fid);
k=k+1;
end
fclose(fid)
Insert what you want in the cell array out. Then save it in the original file
fid= fopen('file.m','w')
for k=1:numel(out)
fprintf(fid,'%s\n',out{k})
end
fclose(fid)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!