The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: square wave
Replies: 1   Last Post: Dec 5, 2012 10:33 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 17
Registered: 10/18/12
Re: square wave
Posted: Dec 5, 2012 10:33 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"dwi" wrote in message <k9lhks$9ud$>...
> I have a square wave which I have scaled to be in the interval [0,1].I want to put the value 1 when I have a square pulse and zero otherwise (so as when summing the sequential aces I would have the duration of each the pulse). THen I want to plot the original wave and the one with the zeros and aces in the same graph. I did this:
> data=sima
> %scale
> simafin=(sima-min(sima))/(max(sima)-min(sima));
> plot(simafin);
> simafin=round(simafin);
> b(1:simafin(1)) = zeros(1,simafin(1));
> for ii = 2:length(simafin)
> if mod(ii,2)==0
> b = [b ones(1,simafin(ii))];
> else
> b = [b zeros(1,simafin(ii))];
> end
> end
> hold on
> plot (b,'m')
> but when i tried to plot b, its pulses weren't in the same place as the pulses of simafin.Any ideas what I'm doing wrong?

Just a clarification:
My data aren't actually a square wave but it has noise, thus the round command

Date Subject Author
Read square wave
Read Re: square wave

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.