So I need to make a function that will be called as function [t, pulse] = PAM (array). My function should have a result like this when I use array = [1 0.3 0.8 0.6], which array is the width of my digital pulsing signal.
Asked
Active
Viewed 138 times
3
Aggelos M
- 41
- 5
-
2Download the book linked at the bottom of the page here: https://sethares.engr.wisc.edu/telebreak.html and read chapter 8. – MBaz Jan 20 '21 at 01:06
-
1Welcome to SE.SP! I'd recommend what MBaz suggests. Chapter 8 seems to have a good exposition of how to convert between bits and symblos. I don't think MBaz is either Rick or Bill. (MBaz, if you are, Hi!). – Peter K. Jan 20 '21 at 13:36
-
1@PeterK. I'm neither :-) I'm just a big fan of their books. – MBaz Jan 20 '21 at 13:56
3 Answers
1
Solved it!
function [t, pulse] = PAM (array)
syms t
u(t) = heaviside(t);
pulse = array(1)*u(t);
for i = [2:length(array)]
if array(i) > array(i - 1)
pulse += abs(array(i-1)-array(i)).u(t - (i-1));
else
pulse -= (array(i-1)-array(i)).u(t-(i-1));
endif
endfor
endfunction
Aggelos M
- 41
- 5
0
It is much easier and faster to use the kron function as below
function [t, pulse] = pam(array,B,fs)
pulse=kron(array,ones(1,fs/B));
t=(0:length(pulse)-1)/fs;
where fs is the sampling frequency and B is the bandwidth of the pulse.
Harris
- 477
- 2
- 5
