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.

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

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));
      pulse -= (array(i-1)-array(i)).*u(t-(i-1));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.