Forums

create a pulse waveform from 200 samples of 1

Started by sreejyothi jonnalagadda November 22, 2002
hai
I tred to create a pulse waveform from 200 samples
of 1 with this code
samples=sign(randn(200,1));
plot(samples(1:200)).
But i am not getting correct result.Is there any
other way to do it



What do you expect to get?
It will be easier to view if you use stem.
-----Original Message-----
From: sreejyothi jonnalagadda [mailto:]
Sent: Friday, November 22, 2002 10:22 AM
To:
Subject: [matlab] create a pulse waveform from 200 samples of 1 hai
I tred to create a pulse waveform from 200 samples
of 1 with this code
samples=sign(randn(200,1));
plot(samples(1:200)).
But i am not getting correct result.Is there any
other way to do it _____________________________________
Note: If you do a simple "reply" with your email client, only the author
of this message will receive your answer. You need to do a "reply all" if
you want your answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join:

To Post:

To Leave:

Archives: http://www.yahoogroups.com/group/matlab

More DSP-Related Groups: http://www.dsprelated.com/groups.php3



sreejyothi,
it's better if you do this:
y = round(rand(1,200));
stem(y)
-----Original Message-----
From: sreejyothi jonnalagadda [mailto:]
Sent: Friday, November 22, 2002 10:22 AM
To:
Subject: [matlab] create a pulse waveform from 200 samples of 1 hai
I tred to create a pulse waveform from 200 samples
of 1 with this code
samples=sign(randn(200,1));
plot(samples(1:200)).
But i am not getting correct result.Is there any
other way to do it _____________________________________
Note: If you do a simple "reply" with your email client, only the author
of this message will receive your answer. You need to do a "reply all" if
you want your answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join:

To Post:

To Leave:

Archives: http://www.yahoogroups.com/group/matlab

More DSP-Related Groups: http://www.dsprelated.com/groups.php3

_____________________________________
Note: If you do a simple "reply" with your email client, only the author of this
message will receive your answer. You need to do a "reply all" if you want your
answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join:

To Post:

To Leave:

Archives: http://www.yahoogroups.com/group/matlab

More DSP-Related Groups: http://www.dsprelated.com/groups.php3 Louis Angeles
BS Electrical Engineering
George Mason University




I think you want:
samples = ones(200,1);

Glen Ragan



Hi:
First of all, as far as I remember sign function gives
you out -1,0 and 1 value depending on the inout value.
Randn function gerenerates random valuse varies from
[-1 1 ], then the output you see will have some many
signum(t) function (signal processing). Anyway if you
expain the probelem clearly then we can help yo more.

thota


Hi,

samples=sign(randn(200,1)); The output depends on the random
numbers. And if you have not set the seed value or state of the random
generator each time you run the program you will get different output. Also,
you will get a pulse waveform of varying pulse width because it just depends
on the random numbers.

If you would like to create a pulse waveform of varying pulse width
then the above statement with little modification will give you the same
results each time you run the program.
randn('state',S) where S is some state Eg:randn('state',33333)
samples=sign(randn(200,1));

Or else if you would like to create a pulse waveform of some fixed
pulse width, for Eg:For 5 samples it should be 1, next 15 samples it should
be 0 and then for next 5 samples it should be -1 then again zero for 15
samples.
x = [ones(1,5) zeros(1,15) -1*ones(1,5) zeros(1,15)];
Now totally you have 40 samples. You can make it 200 samples by repetition
of the same for 5 times. i,e., samples = [x x x x x]; You can change the
pulse width as it suits your requirement.

Regards,
Malini
------
*Disclaimer*
"This e-mail and any attachments are confidential and may contain trade
secrets or privileged or undisclosed information. They may also be subject
to copyright protection. Please do not copy, distribute or forward this
email to anyone unless authorised. If you are not a named addressee, you
must not use, disclose, retain or reproduce all or any part of the
information contained in this e-mail or any attachments. If you have
received this email by mistake please notify the sender immediately by
return email and destroy/delete all copies of the email."
-----Original Message-----
From: sreejyothi jonnalagadda [mailto:]
Sent: Friday, November 22, 2002 11:52 PM
To:
Subject: [matlab] create a pulse waveform from 200 samples of 1 hai
I tred to create a pulse waveform from 200 samples
of 1 with this code
samples=sign(randn(200,1));
plot(samples(1:200)).
But i am not getting correct result.Is there any
other way to do it
_____________________________________
Note: If you do a simple "reply" with your email client, only the author of
this message will receive your answer. You need to do a "reply all" if you
want your answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join:

To Post:

To Leave:

Archives: http://www.yahoogroups.com/group/matlab

More DSP-Related Groups: http://www.dsprelated.com/groups.php3

">http://docs.yahoo.com/info/terms/