Hi Saima,
To generate a variable for wavelet decomposition from your 2D EEG dataset in MATLAB, you can directly create a cell array or structure to hold your channel data for each sample. Below is a sample MATLAB code assuming your data variable is in a cell array with each cell containing a 5209X16 matrix for each sample.
% Parameters
numSamples = 10;
numTimePoints = 5209;
numChannels = 16;
% Generate random EEG data
data = cell(numSamples, 1);
for i = 1:numSamples
data{i} = rand(numTimePoints, numChannels);
end
% extracting channel data for wavelet decomposition
Ch = cell(numSamples, numChannels);
for i = 1:numSamples
currentSample = data{i};
for k = 1:numChannels
Ch{i, k} = currentSample(:, k)';
end
end
% Perform wavelet decomposition on each channel
waveletName = 'db1';
for i = 1:numSamples
for k = 1:numChannels
[cA, cD] = dwt(Ch{i, k}, waveletName);
fprintf('Sample %d, Channel %d: cA size = %d, cD size = %d\n', i, k, length(cA), length(cD));
end
end
In the above code, the ‘Ch’ cell array is used to store each channel’s data as a row vector for each sample. The outer loop goes through each sample, while the inner loop extracts each channel and transposes it to a row vector. The ‘dwt’ function is then used to perform the discrete wavelet transform on each channel. For more information regarding cell arrays, and ‘dwt’ function, refer the following documentation links: