CWT on each frequency one at a time

6 visualizaciones (últimos 30 días)
ryoroy
ryoroy el 5 de Jun. de 2024
Respondida: Swastik Sarkar el 20 de Ag. de 2024
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 comentarios
ryoroy
ryoroy el 5 de Jun. de 2024
According to the documentation for CWT, we can specificy ts or fs. Should I call whatever frequency band I want to here to get the CWT for one frequency band? And what frequency band should I specificy? Is it the central frequency of our wavelet?
Thank you!
Mathieu NOE
Mathieu NOE el 6 de Jun. de 2024
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

Iniciar sesión para comentar.

Respuestas (1)

Swastik Sarkar
Swastik Sarkar el 20 de Ag. de 2024
Hi @ryoroy,
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.

Categorías

Más información sobre Continuous Wavelet Transforms en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by