MATLAB Answers

0

How to stem positive part of wave?

Asked by vu ngothanh on 11 Dec 2015
Latest activity Commented on by vu ngothanh on 12 Dec 2015
Hi everyone,
I have a wave data, I need to show dispersion wave, so I need to "Stem" a "positive part" of the wave (look like the image below). Could you please to help me to solve it.
Thank you in advance.

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by Prasad Kalane on 11 Dec 2015
Edited by Prasad Kalane on 11 Dec 2015
 Accepted Answer

Try using following code
if true
% code
endx1=rand(1,10);
x2=rand(1,10);
x=[x1 -x2];
subplot(121);stem(x);
title('+ve & -ve Data')
for i=1:length(x)
if sign(x(i))==-1
x(i)=0;
end
end
subplot(122);stem(x);
title('+ve Data')

  1 Comment

Thank you very much. It work perfectly.

Sign in to comment.