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

  • \$\begingroup\$ Request @Signal to mark an answer as accepted if they are satisfied with their application, to help any future readers \$\endgroup\$ – shreyas Apr 24 at 10:45
  • 1
    \$\begingroup\$ @Shreyas It's customary to wait at least 24 hours after the question has been asked before accepting an answer. \$\endgroup\$ – pipe Apr 24 at 12:15

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.


The matlab way, using logical indexing:

t = -4*pi:.01:4*pi;
a = sin(t);
a(a <= 0) = 0;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.