How can i Reshape columns for 34400x202 table
1 次查看(过去 30 天)
显示 更早的评论
I'm trying to write a script for music genre classification. I have two different feature matrixes. First matrix takes 80 wav files for each genres. That makes 800 rows and 202 feature columns. My second feature matrix is wavelet. Wavelet feature matrix takes 80 wav files for each genres but it multiplies it by 43. And that makes 800*43 rows and 202 columns as well. How can i reshape it to 800 rows / 202 columns?
ads = audioDatastore(location,'IncludeSubFolders',true,'LabelSource','foldernames');
countEachLabel(ads)
rng(100);
ads = shuffle(ads);
[adsTrain,adsTest] = splitEachLabel(ads,0.8);
numTrain = countEachLabel(adsTrain)
numTest = countEachLabel(adsTest)
trainLabels = adsTrain.Labels;
testLabels = adsTest.Labels;
sn = waveletScattering('SignalLength',2^19,'SamplingFrequency',22050,'InvarianceScale',0.5);
N = 2^19;
batchsize = 64;
scTrain = [];
useGPU = true; % Set to true to use the GPU
while hasdata(adsTrain)
sc = helperbatchscatfeatures(adsTrain,sn,N,batchsize,useGPU);
scTrain = cat(3,scTrain,sc);
end
numTimeWindows = size(scTrain,2);
Nkeep=202; % size to keep
[~,npaths] = sn.paths();
Npaths = sum(npaths);
TrainFeaturesWavelet = permute(scTrain,[2 3 1]);
TrainFeaturesWavelet = reshape(TrainFeaturesWavelet,[],Npaths,1); % wavelet time scattering
TrainFeaturesWavelet = (TrainFeaturesWavelet(1:end,1:Nkeep));
numTrainSignals = numel(trainLabels);
trainLabelsWavelet = repmat(trainLabels,1,numTimeWindows);
trainLabelsWavelet = (reshape(trainLabelsWavelet',numTrainSignals*numTimeWindows,1));
I attached label matrices as png. My point is, in normal train label matrix it goes by blues, clas, disco.... But in wavelet, it goes by same variables but; blues*43 , clas*43, disco*43..
2 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Signal Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!