Error with delta function Matlab 2019

Hello, I have been trying to get the delta function to work with my version of Matlab 2019. I have tried various combinations of code but I keep getting the errors when I try to use delta, even when I declare it as a variable.
Here's an example that I think should work but I keep getting this error. Can someone point me in the right direction of what I am missing?
error:
Insufficient number of outputs from right hand side of equal sign to satisfy assignment.
Here's the code I'm trying to run..
close all;
clc
N = 60; n = 0:N-1;
b = [0.18 0.1 0.3 0.1 0.18];
a = [1 -1.15 1.5 -0.7 0.25];
[d nd] = delta(n(1),0,n(end));
[u nu] = unitstep(n(1),0,n(end));
y1 = filter(b,a,d);
y2 = filter(b,a,u);
Thanks

 Accepted Answer

I have no idea what you actually want to do.
It is generally appropriate to use filtfilt rather than filter for signal processing applications, and to put the excitation signal in the centre of the vector, especaially if you want to do Fourier transforms on it later. Also, I can find no reference for either ‘delta’ or ‘unitstep’. I have substituted the functions that I can find references for.
Try this:
N = 60; n = 0:N-1;
b = [0.18 0.1 0.3 0.1 0.18];
a = [1 -1.15 1.5 -0.7 0.25];
d = dirac(1);
u = heaviside(1);
nd = n;
nu = n;
nd(N/2) = d;
nu(N/2) = u;
y1 = filter(b,a,nd);
y2 = filter(b,a,nu);
figure
plot(n, y1, n, y2)
grid
Experiment to get the results you want.

4 Comments

S Foggie’s Answer moved here —
Hello & Thanks for the response
I am studying DSP and trying to use the filter function to find the impulse and step response of a DSP system. The 'delta' function is used throughout my textbook examples but I have yet to be able to use with my 2019 student version. I'll try this code as I build my model and see how it matches the calculations
However you're correct, I can't find the 'delta' -(I saw the dirac function as you mentioned) --or 'figconfg' command in my MATLAB help search either but I see simple examples using these commands??? I'm not sure if some of these commands were in earlier versions but it error in my 2016 version also......
My pleasure!
Experiment with my code. It works best with filtfilt because that function produces phase-neutral results, regardless of the filter design. (In hardware continuous-time filters, that is only true of Besel filters.) The filter function results will exhibit phase-lag and phase distortion.
It depends on what you want to do.
Note that filtfilt and several other useful functions require the Signal Processing Toolbox.
I doubt that there are significant differences between R2019b and R2020a (that I am using) with respect to those functions. For optimal results, be certain that you have installed all the Updates to R2019b.
Thank you again! This information was very helpful
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Sign in to comment.

More Answers (0)

Products

Release

R2019b

Community Treasure Hunt

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

Start Hunting!