CWT on each frequency one at a time
조회 수: 6 (최근 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 Sarkar
2024년 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!