필터 지우기
필터 지우기

how to make the length of culums equal

조회 수: 3 (최근 30일)
Kamil Kacer
Kamil Kacer 2020년 11월 28일
답변: Walter Roberson 2020년 11월 28일
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

채택된 답변

Walter Roberson
Walter Roberson 2020년 11월 28일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by