Insert a string into code
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
ly
el 20 de Oct. de 2015
Comentada: ly
el 20 de Oct. de 2015
I want to insert a string in to code:
...
name='time';
filename = 'name_v1.txt';
...
Can the 'time' be inserted in " name_v1.txt"?
0 comentarios
Respuesta aceptada
Geoff Hayes
el 20 de Oct. de 2015
ly - if the idea is to replace the 'name' substring within 'name_v1.txt' with 'time', then you could use strrep to accomplish this. For example,
filename = 'name_v1.txt';
filename = strrep(filename,'name','time');
would set filename to
filename =
time_v1.txt
name = 'time';
filename = sprintf('%s_v1.txt',name);
which would (agains) set filename to 'time_v1.txt'.
Más respuestas (0)
Ver también
Categorías
Más información sobre Environment and Settings 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!