I am currently creating a Matlab script to generate a file with the characteristics of a signal. This is the code used:
clear;
folder = dir('sonidos');
m = length(folder);
fileW = fopen('caracteristicas.txt','wt');
for i = 3:m
file = strcat('sonidos/', folder(i).name);
fprintf('Leyendo Archivo: %s \n', file);
[y, Fs] = audioread(file);
max = max(y);
mean = mean(y);
min = min(y);
median = median(y);
peak2peak = peak2peak(y);
peak2rms = peak2rms(y);
rms = rms(y);
rssq = rssq(y);
std = std(y);
var = var(y);
kurtosis = kurtosis(y);
power = (norm(y)^2)/length(y);
fprintf('Caracteristicas: %f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f \n', ...
Fs, max, mean, min, median, peak2peak, peak2rms, rms, rssq, std, var, kurtosis, power);
fprintf(fileW,'%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f \n', ...
Fs, max, mean, min, median, peak2peak, peak2rms, rms, rssq, std, var, kurtosis, power);
end
fclose(fileW);
What I want is to read the sound files in the 'sounds' directory, get the characteristics of the signal and then write the obtained characteristics in a flat file.
When it enters the first cycle the program works fine, but in the second cycle the following appears:
Subscript indices must either be real positive integers or logicals.
Any ideas to solve the error? Thanks