CWT on each frequency one at a time
35 次查看(过去 30 天)
显示 更早的评论
I have a very large matrix (512x1500000) and I want to run CWT on each row. However, since CWT creates a new dimension with its frequency bands, I am running into memory issues. I do not need to store all frequency bands; I just need to run the analysis on each frequency band individually. So, I am wondering if there is a way to run CWT on each frequency band one at a time in a for loop.
3 个评论
Mathieu NOE
2024-6-6
I wonder if you could also do a n th octave analysis , so passing each data (channel) inside bandpass filter (with a for loop to switch to the next band) , then you could buffer the output of the filter and take the rms for a given time period and you would end up with a kind of n th octave spectrogram
you can then fine tune your frequency and time resoltion by playing with n (the 1/n octave band) , the buffer size and overlap.
just my 2 cents
回答(1 个)
Swastik
2024-8-20,8:20
I attempted to replicate your issue by creating a random matrix “data” of dimension 512x1500000 and running the Continuous Wavelet Transform (CWT) on each row. Here's the sample code I used:
numRows = 512;
numCols = 1500000;
data = randn(numRows, numCols);
for i=1:numRows
disp(i)
cwt(data(i,:))
end
I observed that the memory usage fluctuated between two values, likely due to memory allocation and deallocation during each loop iteration. Initially, the MATLAB process consumed 18GB, which increased to 27GB during the CWT operation on a row.
To optimize the process, I modified the MATLAB code to perform CWT not only row by row but also for each frequency band. This approach reduced the RAM consumption to a constant 11GB, although it increased the computation time.
numRows = 512;
numCols = 150000;
data = rand(numRows, numCols);
scales = 1:10; % Adjust Scales accordingly
cwtResults = cell(numRows, 1);
for i = 1:numRows
cwtRow = cell(1, numCols);
for j = 1:numCols
cwtRow{j} = cwt(data(i, j), scales, ‘morl’);
end
cwtResults{i} = cwtRow;
end
To address your query about performing CWT for a single frequency band, you can use the following approach:
desiredFrequency = 10; % Desired frequency in Hz
desiredTimeScale = 1 / (desiredFrequency * waveletScale);
cwtResult = cwt(data, desiredTimeScale, waveletAlgo);
I hope you find a similar outcome, and this helps you.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Continuous Wavelet Transforms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!