From: Dave Smith on
How do I draw a digital signal on the plot graph? let says I have 10 points incrementing by 1. How do I make the plot graph draw a line from x-axis = 0-1, 1-2, 2-3, 3-4, 4-5, 5-6, 7-8, 8-9, 9-10, etc. The line can be at y-axis = 1, 0, or -1 depend on what I want at those points? Lines also have to be connected as well so it's like a digital signal. I'm looking for a for loop that can do this or something better.
From: dpb on
Dave Smith wrote:
> How do I draw a digital signal on the plot graph? let says I have 10
> points incrementing by 1. How do I make the plot graph draw a line from
> x-axis = 0-1, 1-2, 2-3, 3-4, 4-5, 5-6, 7-8, 8-9, 9-10, etc. The line can
> be at y-axis = 1, 0, or -1 depend on what I want at those points? Lines
> also have to be connected as well so it's like a digital signal. I'm
> looking for a for loop that can do this or something better.

just make a data stream that matches the desired waveform...

x=[0:10];
y=rand(size(x));
y(y>.6)=1; y(y<.3)=-1,y(y>.3 && y<.6)=0;
plot(x,y)

--
From: Dave Smith on
dpb <none(a)non.net> wrote in message <hn0k4h$9c1$1(a)news.eternal-september.org>...
> Dave Smith wrote:
> > How do I draw a digital signal on the plot graph? let says I have 10
> > points incrementing by 1. How do I make the plot graph draw a line from
> > x-axis = 0-1, 1-2, 2-3, 3-4, 4-5, 5-6, 7-8, 8-9, 9-10, etc. The line can
> > be at y-axis = 1, 0, or -1 depend on what I want at those points? Lines
> > also have to be connected as well so it's like a digital signal. I'm
> > looking for a for loop that can do this or something better.
>
> just make a data stream that matches the desired waveform...
>
> x=[0:10];
> y=rand(size(x));
> y(y>.6)=1; y(y<.3)=-1,y(y>.3 && y<.6)=0;
> plot(x,y)
>
> --

Thank you. This is very close to what i wanted but can you explain what is rand(size(x)) do? I ran this on matlab and I'm getting a diagonal line going from says 1-2. but I only want horizontal line so like 0-1 is a horizontal line and a vertical line going down from 2 and then another horizontal line from 2-3. I hope you understand what I'm trying to said.
From: dpb on
Dave Smith wrote:
> dpb <none(a)non.net> wrote in message
> <hn0k4h$9c1$1(a)news.eternal-september.org>...
....

> Thank you. This is very close to what i wanted but can you explain what
> is rand(size(x)) do?

Just generated a set of random numbers to start w/ of the same size as x...

....

> a horizontal line and a vertical line going down from 2 and then another
> horizontal line from 2-3. I hope you understand what I'm trying to said.

Yeah, you'll have to duplicate the x-coordinates at the break points
which the above doesn't do (didn't think thru the issue thoroughly enuf
before, sorry).

The fundamental idea is the same, just that you'll have to have the x
and y vectors contain the entries for both the (replicating) abcissa and
ordinates to draw a true square wave. What I showed would be a
triangle, indeed.

Of course, a true square wave is an idealization anyway, no matter how
good the rise/fall time of a wave generator... :)

If you perchance have the Signal Processing toolbox, it has a square()
function but it is "realizable" in the above sense as it doesn't
generate values at duplicated time points, either.

--
From: Dave Smith on
dpb <none(a)non.net> wrote in message <hn0uph$jl1$1(a)news.eternal-september.org>...
> Dave Smith wrote:
> > dpb <none(a)non.net> wrote in message
> > <hn0k4h$9c1$1(a)news.eternal-september.org>...
> ...
>
> > Thank you. This is very close to what i wanted but can you explain what
> > is rand(size(x)) do?
>
> Just generated a set of random numbers to start w/ of the same size as x...
>
> ...
>
> > a horizontal line and a vertical line going down from 2 and then another
> > horizontal line from 2-3. I hope you understand what I'm trying to said.
>
> Yeah, you'll have to duplicate the x-coordinates at the break points
> which the above doesn't do (didn't think thru the issue thoroughly enuf
> before, sorry).
>
> The fundamental idea is the same, just that you'll have to have the x
> and y vectors contain the entries for both the (replicating) abcissa and
> ordinates to draw a true square wave. What I showed would be a
> triangle, indeed.
>
> Of course, a true square wave is an idealization anyway, no matter how
> good the rise/fall time of a wave generator... :)
>
> If you perchance have the Signal Processing toolbox, it has a square()
> function but it is "realizable" in the above sense as it doesn't
> generate values at duplicated time points, either.
>
> --

duplicate x-coordinates? can you help me out, I been struggling with this all day, so frustrating