Borrar filtros
Borrar filtros

I try to write audiofiles from data which is stored in a struct

1 visualización (últimos 30 días)
Lutz
Lutz el 21 de Dic. de 2022
Comentada: Lutz el 21 de Dic. de 2022
Hey guys,
im working on a loop which goes trough a struct and saves every datastore into a .wav data. The files shoud have all the same name with an number - like - JD1; JD2;JD3, etc... it would also be possible to have the number in ()...
here is my code:
for i = 1:length(data_store) % data:store is a cell
struc(i).tones = data_store{i} % the loop puts all data into one struct
end
% give me the amount of tones
length(struc)
% Save the cutted part
filename = 'C:\Users\blabla\Single_Tones\JD'
for i = 1:length(struc)
audiowrite(filename(i),struc(i).tones,Fs);
end
Thanks!

Respuesta aceptada

Jan
Jan el 21 de Dic. de 2022
Editada: Jan el 21 de Dic. de 2022
folder = 'C:\Users\blabla\Single_Tones\'
for i = 1:length(struc)
file = fullfile(folder, sprintf('JD(%d).wav', i));
audiowrite(file, struc(i).tones, Fs);
end
Is there a reason for the indirection of a struct? You can write the contents of data_store{i} directly also.
  1 comentario
Lutz
Lutz el 21 de Dic. de 2022
There is no reason... I thought it would be easier out of a struct. But I open to use the cell!

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by