use sprintf with .wav files in for-loop
Mostrar comentarios más antiguos
Hi,
How do i properly recall a .wav file in a for-loop? Changing the name of the variable with sprintf gives me an error.
[wav1,Fs] = audioread('wav1.wav');
[wav2,Fs] = audioread('wav2.wav');
[wav3,Fs] = audioread('wav3.wav');
n = 3;
for k = 1:n
wavx = sprintf('wav%d', k);
[acor,lag] = xcorr(wav1,wavx);
end
I hope someone can help me, thanks a lot in advance!
3 comentarios
Von Duesenberg
el 10 de Mayo de 2018
I wouldn't do this if I were you. The easiest solution I think if your files have the same number of samples would be to import them directly into a matrix and then you can loop through the columns of the matrix.
harrie houthakker
el 10 de Mayo de 2018
Von Duesenberg
el 10 de Mayo de 2018
Editada: Von Duesenberg
el 10 de Mayo de 2018
In this case you may want to store the your signals in a cell array and then loop through your cell array. And xcorr does the padding for you.
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 10 de Mayo de 2018
1 voto
2 comentarios
harrie houthakker
el 10 de Mayo de 2018
Jan
el 10 de Mayo de 2018
@harrie: The application of xcorr is not a problem in any way, if you use a cell array. wav{1} is much better than wav1, because you can access it easily in a loop.
Categorías
Más información sobre Array and Matrix Mathematics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!