3
$\begingroup$

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.

result

$\endgroup$
3
  • 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, 2021 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, 2021 at 13:36
  • 1
    $\begingroup$ @PeterK. I'm neither :-) I'm just a big fan of their books. $\endgroup$
    – MBaz
    Jan 20, 2021 at 13:56

3 Answers 3

1
$\begingroup$

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
$\endgroup$
0
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

Look into the repelem() function.

$\endgroup$

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.