Sampling from a random pulse train using pulstran
Ältere Kommentare anzeigen
I am trying to generate and sample from a random pulse train with amplitude A that is uniformly distributed over (0,1); that has a width of 0.5 seconds and a period of one seconds. I am trying to write a routine that will generate 100 discrete samples of the random pulse train and plot two of the sequences. The sampling rate of the pulse train is 10hz. I have attempted a solution but keep getting this error:
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
Error in random_pulse_a3 (line 13)
X(i,1:100) = pulstran(t,d,@rectpuls,w);
I have tried fixing this error myself and am not understanding what is wrong. Any help explaining what ive done wrong would be appreciated and how to fix it. Thank you
function X = random_pulse_a;
fs=10;
t=[0:1/fs:5];
w = 0.5;
A = rand(100, 1);
for i = 1:100
B(1:1, 1:6) = A(i,1);
d=[0.2:1:5.2;B]';
X(i,1:100) = pulstran(t,d,@rectpuls,w); %error occurs here
end
x = random_pulse_a;
plot (x(1,1:100))
hold on
plot (x(2,1:100))
Antworten (0)
Kategorien
Mehr zu Waveform Generation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!