1
\$\begingroup\$

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

\$\endgroup\$
  • \$\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
5
\$\begingroup\$

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.

\$\endgroup\$
2
\$\begingroup\$

The matlab way, using logical indexing:

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

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.