Effacer les filtres
Effacer les filtres

How to change code in scripts using command

16 vues (au cours des 30 derniers jours)
Joyce Taylor
Joyce Taylor le 30 Avr 2016
Commenté : Deep Manvar le 22 Déc 2020
Certainly ,i could change it manually.But using command along with Conditional statements can achieve this process automatically.

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 30 Avr 2016
Modifié(e) : Azzi Abdelmalek le 30 Avr 2016
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)

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by