Electronic – What expression can I use in matlab to remove the negative component of a sine wave so it can look like the picture below

design

The image shows a sine wave is obtained using MATLAB. I would like to know what they possibly multiplied or what expression could one use in MATLABto get this wave instead of a complete sine wave.enter image description here

Best Answer

I don't know MatLab but I suspect that (y + |y|)/2 (where |y| is the absolute value of the function) would do the trick.

When the function is positive the two halves add to give a regular sine. When the function is negative the function and absolute value cancel out.