Creating a PAM function with Matlab
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) &gt; 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