1

I've started to learn signal fundamentals and I have to do one exercise and I can't understand something.

It is said that $$x[n]=3\cos(0.1 \Pi n)(u[n+55]-u[n-55]))$$ and that the signal $u[n-m]$ is a unit step with the value $0$ for $n<m$ and $1$ for $n\geq m$

I have made this MatLab function to plot this signal.

function x = signal(n)
    % n is passed as n = -100:100;%
    x = zeros(1,length(n));

    for i=1:length(n)
        if n(i)>-55 && n(i) < 55
            x(i) = 3*cos(0.1*pi*n(i));
        else
            x(i) = 0;
        end
    end
end

Is this OK? I'm having doubt's because I can't understand what $(u[n+55]-u[n-55]))$ means...

Mikasa
  • 67,374
Favolas
  • 803
  • 1
  • 8
  • 15

1 Answers1

1

You gave the definition of $u[n]$ in your post: $u[n]=\begin {cases} 0 & n \lt 0 \\ 1 &n \ge 0 \end {cases}$ Using that $u[n-55]=\begin {cases} 0 & n \lt 55 \\ 1 &n \ge 55 \end {cases}$ and $u[n+55]=\begin {cases} 0 & n \lt -55 \\ 1 &n \ge -55 \end {cases}$

Ross Millikan
  • 374,822
  • Thanks. I think I now understand. With your explanation I've made some test calculations on the "limits" and I think the for loop has to be if n(i)>=-55 && n(i) < 55 instead of if n(i)>-55 && n(i) < 55 Am I right? – Favolas Feb 23 '13 at 16:38
  • @Favolas: that is correct. – Ross Millikan Feb 23 '13 at 21:41