using the int i as output name
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sobel Captain
el 19 de Nov. de 2015
Hi,everyone.I would like to ask a question about using the int i as output name , I hope someone could help me . such as for i=1:30; I have a function I would like to put 30 different input using for loop . just like input (i)=xxx ->my program->output (i)=xxxx I would like to have 30 input(some audio files 1.wav 2.wav 3.wav ............) and 30 output , output 1 output 2 output 3......, I have tried output(int i) that's not works , also int2str(i) not working too. could anyone tell me how to do that , thanks a lot .
0 comentarios
Respuesta aceptada
Más respuestas (2)
Thorsten
el 19 de Nov. de 2015
This is a possible framework of how to process 30 files:
for i = 1:30
input_filename = sprintf('%d.wav', i)
% read input_fileame, compute output
output_filename = sprintf('output%d', i)
% write output to file
end
2 comentarios
Thorsten
el 19 de Nov. de 2015
Editada: Thorsten
el 19 de Nov. de 2015
You can create dynamically named variables with eval, but this is not considered good programming practice:
eval(['ans', int2str(i) '= myans;'])
Instead, if myans has a different size for different i, use
ans{i} = myans;
or, if myans has the same size for all i:
ans(i) = myans; % if myans is a single value
or
ans(i,:) = myans; % if myans is a 1xn vector
or
ans(i, :,:) = myans; % if myans is a n x matrix
and so on.
Ver también
Categorías
Más información sobre Whos 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!