MATLAB: How to create a mat file in a loop and store a matrix generated in that newly created mat file? (i also need to save every created mat file in the loop)

.mat fileaudio processingfile handlingsprintf

I tried with the following code but it says
for j=0:0
for k=0:1
filename=sprintf('%d%d.wav',j,k);
sin_of_sin=audioread(filename);
[st_matrix] = st_temp(sin_of_sin); % st_temp is my function file which returns the generated matrix
sprintf('angry_%d%d.mat',j,k)=st_matrix;
end
end
Error message:
Subscript indices must either be real positive integers or logicals.

Best Answer

Instead of assigning a matrix to the sprintf() function, which of course you cannot do,
sprintf('angry_%d%d.mat',j,k)=st_matrix; % Bad syntax!!!
try this:
matFileName = fullfile(pwd, sprintf('angry_%d%d.mat',j,k));
save(matFilename, 'st_matrix');