writing convolution function in matlab?

It is basically assignment. I have to make a MATLAB function to systematically develop the sequence y[n] generated by the convolution of the
two-finite length sequence x[n] and ?[?]. Program should be able to handle causal and non- casual sequences.
Program should call for the input sequences and their indices vectors .
Below is my code
function [ny,y ] = convolution(nx,x,nh,h )
%UNTITLED7 Summary of this function goes here
% Detailed explanation goes here
a=nx(1)+nh(1) %nx is time span of x and nh is time span of h
b=nx(length(x))+nh(length(h))
ny=[a:b]% ny is length of y
y=conv(x,h)
end
Please kindly guide me and correct me,if my code is not as per requirment/question?

5 commentaires

Image Analyst
Image Analyst le 22 Fév 2020
Are you allowed to use the built-in conv() function in your assignment to create a convolution function?
ABTJ
ABTJ le 23 Fév 2020
Yes. But i dont understand ,how to do the part"Program should be able to handle causal and non- casual sequences.
Program should call for the input sequences and their indices vectors ." ??
Image Analyst
Image Analyst le 23 Fév 2020
It's when you slide the filter along the signal, whether the half of the filter that deals with later (future) time indexes should be zeroed out or not. If they're zeroed out then "future" times won't affect the filtered signal value.
ABTJ
ABTJ le 23 Fév 2020
What is meant by"indices vector" here?Is it meaning time indexes,which i have denoted by nh and nx in my function?
Matt J
Matt J le 23 Fév 2020
That's a question for the person who gave you the assignment.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Signal Processing Toolbox dans Centre d'aide et File Exchange

Produits

Version

R2015a

Question posée :

le 22 Fév 2020

Commenté :

le 23 Fév 2020

Community Treasure Hunt

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

Start Hunting!

Translated by