How to implement a difference equation, and get output signal from giving it input signals?

2 views (last 30 days)
I have a "hcanald.p" file that contains a function that returns me a signal, which represents the unit-pulse response of my system (the system will be called S). What I want to do is to create a function that implements the system "S" and then be able to use this function to call it with an input signal and obtain the output.
The signal obtained from hcanald(754) is described by the following equation: ( d(n) is the kronecker-delta function )
h(n) = d(n) + 0.4 * d(n-8821) + 0.16 * d(n-17640)
%this is not matlab code
This is what it looks: ( stem(h) )
Any system is described by the convolution of an input signal with the unit-pulse response of the system. By knowing the unit-pulse response, I can obtain a difference equation for the system and it looks like follow:
y(n) = x(n) + 0.4 * x(n-8821) + 0.16 * x(n-17640)
%this is not matlab code
My code is the following:
S.m
function [ y ] = S( x, n )
y(n)=x(n)+0.4*x(n-8821)+0.16*x(n-17640);
end
ex1_1.m
h = hcanald(754); %hcanald is the function from the .p file
%754 is a random value
fig = stem(h); %creates the discrete plot for "h"
y = S( , ); % -- this is where I don't know how to test the system function
% -- I want to input a kronecker delta to see if I get the unit-pulse response I already have
Resuming,
  • Does the function S.m works properly and has the correct arguments ?
  • How to use that function and apply to it the kronecker-delta or aka unit pulse ?
Thank you for reading this, I hope you can help me.

Answers (1)

Juan Ramallo
Juan Ramallo on 27 Oct 2015
I am using this function to represent the kronecker-delta:
function d = kronDel(j,k)
if j == k
d = 1;
else
d = 0;
end

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!