making a data series with 2 or 3 discrete pulse, rest are zero

Hello, I am new to matlab. I want to prepare a data series of say 1024, with 2 or 3 sharp pulses at discrete positions. I want rest points to be zero (preferable) or very small values, so that I can really identify the pulses. Later, if I want to add a normally distributed random noise, how I can do that. thanks a lot in advance. regards. asim

Risposte (1)

Series=zeros(1024,1);
RandPos=[10,13,50];
PulseHeight=2;
Series(RandPos)=PulseHeight;
Noise=rand(1024,1);
Signal=Series+Noise;
plot(Signal);

6 Commenti

Thank you so much. its great.
I was just wondering if it is possible to create the pulse as harmonics. For example, i want to present the series as the harmonics in sine wave. The pulses will be there but in the form of harmonics.
thanks again.
regrds.
asim
in addition to Jiang's code,
impulse_response=[1 2 3 2 1];
waveform = conv(Series,impulse_Response);
plot(waveform)
@Jinag, thanks.
@Chen, thank you so much. It better. I was wondering of creating the series as harmonics as a function of sine or cosine wave. Can I do this? thanks.
@Asim, then you need to specify the frequency, magnitude, also the time steps for your 1024 data point.
Thanks Jiang. I appreciate it.
lets say, 0.1 sec interval from 0.1 to 10.24 sec. I want a resonable frequency and say unit magnitude. However, I want to see the pulse for a very short period but high magnitude. It should look like a peak in the middle of no where.
I wonder if I can make the question clear.
thanks a lot.
regards.
asim
All right,the point here is to show you the method, not give you the complete solution. From the above example, I hope you start to understand how easy MATLAB can enable you to do this. To define time, t=0:0.1:10.24. To generate a unit sine wave with frequency f, f=2; Data=sin(2*pi*t); You can use the same method to generate the pulse signal with high frequency and high magnitude. Then to add them together at a certain time spot, you can use for example: Data(51:60)=Data(51:60)+PulseSignal(1:10). Note that your sample time is 0.1sec, which means 10Hz, you can't really represent any signal with frequency high than 5Hz

Accedi per commentare.

Richiesto:

il 22 Ago 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by