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!