How can i use Discrete wavelet transform (DWT) on a matrix

I have data set of 327 subjects i have read all the dataset in one variable that is T1. T1 size is 1 x 327 and each cell has 19200 x 14. i want to read each data and perform dwt on each one data i.e 19200x 1 and i want it in a loop ( like 1 to 14). I want 2 - level dwt and db4 and extract detail and approximation in matrix
Can someone please help me i have done several methods but didn't get the answer
%% READING THE DATA
% Task1
myFolder = 'D:\Finall Sorted data\Task 1';
% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile(myFolder, '*.csv');
theFiles = dir(filePattern);
n = length(theFiles);
for k = 1 : n
baseFileName = theFiles(k).name;
T1{k} = readmatrix(fullfile(theFiles(k).folder, baseFileName));
end
S = [];
P = 0;
sz = 0; % Size of matrix
for i = 1 : 327
S{i} = T1{1,i}; % to read the data
for j = 1 : 14
P = S(1:19200:j);
sz = size(P);
% dwt method
end
end

댓글 수: 5

Hi Sameer,
  • There is a typo in the code P = S(1:19200:j) where j = 1:14. Perhaps, you meant P = S(1:19200,j);.
  • Did you try wavedec2?
Yes, but didn’t get the answer
S{i} = T1{1,i}; % to read the data
Why are you doing that? You are copying from a cell array to a cell array.
P = S(1:19200:j);
S is a cell array, not a numeric array. The result of the () indexing is going to be a cell array.
dwt2() cannot process a cell array.
Sameer Ingale
Sameer Ingale 2023년 2월 4일
편집: Sameer Ingale 2023년 2월 4일
I want the size of data within S.
so what should i use to instead of cell array to process ?
for j = 1 : 14
P = S(1:19200:j);
Suppose j were 1. Then you would have S(1:19200:1) . But the end value is the same as the initial value, so that will be just S(1) . The same is true for all the other values of j from 1 to 14. j would have to be at lest 19201 for 1:19200:j to include more than one element.
Where you for some reason interested in 1:j:19200 ? That is, the first time [1, 2, 3, 4, ...] and the second time [1, 3, 5, 7, ...] and the third time [1 4 7 10, ...] and so on? Or were you interested in S(1:19200,j) ?
size(1:19200,j) is going to be 19200 x 1 unless j is non-scalar (or is the logical value false)
If you want to know about the size of the data in T1 then you would be more likely to use
S = T1{1,i};

댓글을 달려면 로그인하십시오.

답변 (1개)

Nayan
Nayan 2023년 4월 11일

0 개 추천

Hi
As I understand you want to perfrom discrete wavelet transform on a matrix. This can be performed using dwt2(X,wname).
For futher querry you can share the Data and the exact description of problem that you are facing.
Happy to help!

카테고리

도움말 센터File Exchange에서 Wavelet Toolbox에 대해 자세히 알아보기

질문:

2023년 2월 3일

답변:

2023년 4월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by