how to make the length of culums equal

1 visualización (últimos 30 días)
Kamil Kacer
Kamil Kacer el 28 de Nov. de 2020
Respondida: Walter Roberson el 28 de Nov. de 2020
Hi i have code like this I want to scan my folder and for each wav in file( 5 files) i want to compute DFT the I want to fit them in a matrix F which will have 5 columns.
Of course i cannot do it because the size of each wav isnt the same so can you guys help me with this
I can make each wav of same time length and it would work
But what i want to do is for example if first file has 10 000 rows 1 columns and second file 7000 rows and 1 column i want to add 3000 rows of ones into the ceond file and so on for other 3 files.
Make them all equeal so i can find a mean of each row of the 5 files
for (i=1:length(D)) % for each wav file in the given path:
curFileName = [classPath D(i).name];
FileNamesTemp{i} = curFileName;
% mid-term feature extraction for each wav file:
[a] = audioread(curFileName);
% signal = struct('Filt_data', data, 'SampleRate', fs);
if (size(a,2)>1)
a = (sum(a,2)/2);% convert to MONO
end
stFeatures = getDFT(a);
% stFeatures = stFeatureExtraction(a, 44100, stWin, stStep);
% midFeatures = featureExtractionFile(curFileName, ...
% stWin, stStep, mtWin, mtStep, listOfStatistics);
% long-term averaging:
% longFeatures = mean(stFeatures,2);
% F = [F longFeatures];
F(:,i) = stFeatures;
end

Respuesta aceptada

Walter Roberson
Walter Roberson el 28 de Nov. de 2020
numD = length(D);
F = zeros(0, length(D));
for i = 1 : numD
stuff and then
Frows = size(F,1);
numFeat = length(stFeatures);
if Frows < numFeat
%new file is bigger than anything so far, extend all existing rows with 1
F(Frows+1:numFeat, :) = 1;
elseif numFeat < Frows
%new file is smaller than what we have seen so far, extend it with 1
stFeatures(numFeat+1:Frows) = 1;
end
F(:, i) = stFeatures;
end

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by