# Creating a PAM function with Matlab

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.

Also please not a complete answer, I think it's better to think alone, but I'm in a point that I don't know what to do.

• Download the book linked at the bottom of the page here: sethares.engr.wisc.edu/telebreak.html and read chapter 8. – MBaz Jan 20 at 1:06
• Welcome 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 at 13:36
• @PeterK. I'm neither :-) I'm just a big fan of their books. – MBaz Jan 20 at 13:56

## 1 Answer

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