Saving a 2D matrix each loop iteration as a specific file type and name
Mostrar comentarios más antiguos
Hi All, I've had a look at the other answers in the community and none seem to work for me, so here is my problem. In a for-loop, I'm uploading a series of audio files one at a time, reading it as wav data, performing calculations on it (RMS in this case) and then want to save both the y matrix (varying size, 2D) and the RMS array (varying length) each loop iteration, with a specific naming convention.
My code is below:
%Load files
%Define working folder
myfolder = 'H:\ERP2018\Actor 01 Normal Intensity Only;
myDir = 'H:\ERP2018\Actor 01 Normal Intensity Only; %gets directory
myFiles = dir(fullfile(myDir,'*.wav')); %table of file names, size, etc
%forloop
for k = 1:length(myFiles)
baseFileName = myFiles(k).name;
FileName=[baseFileName,num2str(baseFileName)] ;
fullFileName = fullfile(myfolder, baseFileName);
[wavData, Fs] = audioread(fullFileName);
y=wavData; %want to save this each loop through
%split into frames and save as 2D matrix
FrameLen=512;
%gives a frame length of 10.69ms approx
FramesMat= buffer(y, FrameLen);
FramesMat = FramesMat';
%gives matrix of 512 samples by a varying number of frames (about 227 frames)
RMSFramesMat = rms (FramesMat); %want to save this each loop through
end
In each loop, I want to save the y matrix, named as 'originalactor01-k' where k is an incremental as the loop runs, and want to save the RMSFramesMat as an array named 'RMSFramesMatactor01-k'
Ideally, as an excel readable file, unless there are better options, as this will be the basis of a stat analysis for my research. Any help that could be given would be great!
Thanks! Chris
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Standard File Formats 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!