Question

In: Computer Science

function X=extractDWT(x_train,startS,endS,wStep,wRange) % x_train = input signal % startS   = from second % endS     = end...

function X=extractDWT(x_train,startS,endS,wStep,wRange)
% x_train = input signal
% startS   = from second
% endS     = end second
% wStep   = overlapping
% wRange = window size
FS=128;

N=size(x_train,3);
sz=floor((endS-(startS+wRange))/wStep)+1;
X=zeros(sz*140,2);
cn=0;
for i=1:N
   
    for sig=startS:wStep:endS-wRange
       
        sW=sig*FS+1;
        eW=(sig+wRange)*FS;
       
        C3Sig=x_train(sW:eW,1,i);
        C4Sig=x_train(sW:eW,3,i);
       
        waveletFunction = 'db4';
        waveletLevel=3;
        [wCoe,L] = wavedec(C3Sig,waveletLevel,waveletFunction);
        C3D3 = detcoef(wCoe,L,3);   % Mu
       
       
        [wCoe,L] = wavedec(C4Sig,waveletLevel,waveletFunction);
        C4D3 = detcoef(wCoe,L,3); % Mu
       
        cn=cn+1;
        % Mean of the absolute values
        X(cn,1)=sum(C3D3.^2)/numel(C3D3);
        X(cn,2)=sum(C4D3.^2)/numel(C4D3);
    end
end

end

Need code explanation for above code?

Solutions

Expert Solution

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

Below is your code with full comments at each line for explaination


function X=extractDWT(x_train,startS,endS,wStep,wRange)%A function with name extractDWT and several inputs
% x_train = input signal
% startS = from second
% endS = end second
% wStep = overlapping
% wRange = window size
FS=128;%define and initialize Fs as 128

N=size(x_train,3);%number of elements in 3rd dimension of input signal x_train matrix
sz=floor((endS-(startS+wRange))/wStep)+1;%define and initialize sz as the greatest integer less than the ((endS-(startS+wRange))/wStep)+1
X=zeros(sz*140,2);%define X as the zeros matrix with sz*140 rows and 2 columns
cn=0;%initialize cn as 0
for i=1:N% a loop to go from 1 to N

for sig=startS:wStep:endS-wRange% a loop with sig values from startS to endS-wRange in steps of wStep

sW=sig*FS+1;%define sW as sig*Fs+1
eW=(sig+wRange)*FS;%define eW as (sig+wRange)*FS

C3Sig=x_train(sW:eW,1,i);%define C3Sig as the matrix with elements of x_train matrix from sW to eW rows, 1st column and ith 3 dimensional element
C4Sig=x_train(sW:eW,3,i);%define C4Sig as the matrix with elements of x_train matrix from sW to eW rows, 3rd column and ith 3 dimensional element

waveletFunction = 'db4';%define waveletFunction as the char array with characters db4
waveletLevel=3;%define waveletLevel as 3
[wCoe,L] = wavedec(C3Sig,waveletLevel,waveletFunction);%Find the 1-D wavelet decomposition wCoe and L
C3D3 = detcoef(wCoe,L,3); % Mu, finds the wavelet analysis


[wCoe,L] = wavedec(C4Sig,waveletLevel,waveletFunction);%Find the 1-D wavelet decomposition wCoe and L
C4D3 = detcoef(wCoe,L,3); % Mu, finds the wavelet analysis

cn=cn+1;%increment cn by 1
% Mean of the absolute values
X(cn,1)=sum(C3D3.^2)/numel(C3D3);%assign the cn'th row and first column of X to a value as sum of squares of elements of C3D3 divided by length of C3D3
X(cn,2)=sum(C4D3.^2)/numel(C4D3);%assign the cn'th row and second column of X to a value as sum of squares of elements of C4D3 divided by length of C4D3
end
end

end

Kindly revert for any queries

Thanks.


Related Solutions

matlab Q1) a) create a vector that starts at a, ends at b, and has a...
matlab Q1) a) create a vector that starts at a, ends at b, and has a spacing of c (allow the user to input all of these parameters) b)create an inches vector using a,b and c c) calculate the corresponding values of feet in another vector (1feet=12 inches) d) group the inch vector and the feet vector together into a table matrix e)use the disp command to create a title for a table that converts inches to feet f)use the...
The accounting cycle starts with analysis of business transactions and ends with the preparation of a...
The accounting cycle starts with analysis of business transactions and ends with the preparation of a post-closing trial balance. To recap, what is the implication of missing a step. Must the steps be performed following the same sequence? If yes, why is it important to follow the steps?
Heat equation: Arbitrary temperatures at ends. If the ends x = 0 and x = L...
Heat equation: Arbitrary temperatures at ends. If the ends x = 0 and x = L of the bar in the text are kept at constant temperatures U1 and U2, respectively. The initial temp distribution is given by u(x, 0) = f (x). (a) What is the temperature u1(x) in the bar after a long time (theoretically, as t → ∞)? First guess, then calculate. (b) What is the temperature at any t. Use the heat equation given by ut...
Describe a purification scheme that starts with a mixture of cells, virions and proteins and ends...
Describe a purification scheme that starts with a mixture of cells, virions and proteins and ends with a tube containing pure virions. Or, how about obtaining a supernatant solution containing only pure virions?
In Python Write a function to read a Sudoku board from an input string. The input...
In Python Write a function to read a Sudoku board from an input string. The input string must be exactly 81 characters long (plus the terminating null that marks the end of the string) and contains digits and dots (the `.` character represents an unmarked position). The input contains all 9 rows packed together. For example, a Sudoku board that looks like this: ``` ..7 ... ... 6.4 ... ..3 ... .54 ..2 ... .4. ... 9.. ... ..5 385...
Write a function fun(x) that takes as input a positive number x and solves the following...
Write a function fun(x) that takes as input a positive number x and solves the following equation for y and returns y. The equation is 10^4y=x+3. Could you help me with this by using python? I can use loop or if statement for this question.
C++ Question Make a function that adds a linked list to itself at the end. Input:...
C++ Question Make a function that adds a linked list to itself at the end. Input: 4 -> 2 -> 1 -> NULL Output: 4 -> 2 -> 1 -> 4 -> 2 -> 1 -> NULL Note:- code should work on visual studio and provide screenshot of output along with code
Based on fourier series Q1: how to determine if a signal function x(t) is periodic and...
Based on fourier series Q1: how to determine if a signal function x(t) is periodic and ac. And what happens if there is x(t) = sint + cost + sint? How would we know if ac/periodic? Q2: What is fourier series and fourier coefficients? Q3: What is Fourier Trigonometric Series?
A man starts a random walk at a lamp post. a)What is the probability he ends...
A man starts a random walk at a lamp post. a)What is the probability he ends up back at the lamp post after 8 steps? b)There is a wall 3 steps down the path. What is the probability he ends up back at the lamp post after 10 steps? Within 3 steps of the lamp post after 10 steps? c)There is a pit of alligators 3 steps down the path. If he takes 10 steps, what is the probability the...
when fluorescent markers are attached to two ends of a holiday junction, the FRET signal is...
when fluorescent markers are attached to two ends of a holiday junction, the FRET signal is observed to jump between a high efficiency and low efficiency state because of the changes in the choices excitation intensity excitation frequency donor acceptor distance twists in dna
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT