How to use shell commands including variables from matlab?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Pal Szabo
el 20 de Sept. de 2017
Comentada: Pal Szabo
el 20 de Sept. de 2017
I have N files, file1 file2 file3, ... fileN. I know that
!rm file1
removes file1. How can I create a loop, which removes file1 file2 file3 ... fileN? My idea: create array, myfiles = ("myfile1","myfile2","myfile3") Than call:
for i=1:N
!rm myfiles(i)
end
This doesn't work however, matlab tries to remove file "myfiles(i)", not myfile1, myfile2,... myfileN.
How to solve this problem?
0 comentarios
Respuesta aceptada
Walter Roberson
el 20 de Sept. de 2017
for filecell = myfiles
filename = filecell{1};
delete(filename) ;
end
If deletion was just a sample operation
for filecell = myfiles
filename = filecell{1};
cmd = sprintf('rm "%s"', filename );
system(cmd);
end
Más respuestas (0)
Ver también
Categorías
Más información sobre Files and Folders en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!