Is this impossible to be made on MATLAB ?

I need to make a sliding window on Matlab, this window supposed to slide over a signal, the window must be with two halves that's at the middle it's located on sample n for example. and each step it moved to the next sample number, while each step it subtract the energy in the left half of the energy of the right half, if they equal tit returns 0 if they not equal it return a specific value?
Thank you I appreciate your help :))

Réponses (1)

Walter Roberson
Walter Roberson le 4 Mar 2012
Suppose your window is 2*N samples wide (an even width). Then filter() the signal with a kernel which is -1 repeated N times followed by +1 repeated N times. Once you have the filtered signal, then if S is the specific value to return if the two halves are not equal,
S * (filtered_signal ~= 0)
will give you 0 where the two halves were equal, and S where they were not.

3 commentaires

Daniel Shub
Daniel Shub le 4 Mar 2012
Or if the middle point is neither in the left or right, then you want an odd length window with a 0 in the middle.
Shamooooot
Shamooooot le 4 Mar 2012
am sorry am not sure how this is done on matlab ?!
Daniel Shub
Daniel Shub le 4 Mar 2012
Which part? What have you tried so far? One way to make a window is:
win = [-1 -1 -1 1 1 1];
Can you think of an easier way (hint doc ones)?

Cette question est clôturée.

Clôturé :

le 20 Août 2021

Community Treasure Hunt

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

Start Hunting!

Translated by