Borrar filtros
Borrar filtros

How to change code in scripts using command

16 visualizaciones (últimos 30 días)
Joyce Taylor
Joyce Taylor el 30 de Abr. de 2016
Comentada: Deep Manvar el 22 de Dic. de 2020
Certainly ,i could change it manually.But using command along with Conditional statements can achieve this process automatically.

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 30 de Abr. de 2016
Editada: Azzi Abdelmalek el 30 de Abr. de 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)

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by