DSPRelated.com
Forums

unit step response doubt

Started by raj June 25, 2008
Hai,

I have written a unit step matlab code as follows:

h=[0.21193952414828646
0.47183270983487557
0.47183270983487557
0.21193952414828646
];

step= zeros(4,1);
        for     i=1:4
         step(i) =1;
        end;

output = conv(h,step);

output:
0.211939524148286
0.683772233983162
1.155604943818038
1.367544467966324
1.155604943818038
0.683772233983162
0.211939524148286

The above step response is according to boundary conditions:
N+M-1

But using  FDA tool i got only this:

0.211939524148286
0.683772233983162
1.155604943818038
1.367544467966324

The above step response is based on number of input samples = number
of o/p samples

In both the cases u(n)={1,1,1,1}

My objective is i wish to change my MATLAB code so that i should
achieve the same o/p as generated by FDAtool...or Is there way to
store the step responses values of FDAtool?pls suggest.

regards,
raj
You could just use the filter command in matlab,

y = filter(b, a, x);

% x is the step input

% b is same as h in your case;

% a = 1; as you have an FIR, for IIR filter a will start to 
% take on some values.

Regards
Bharat Pathak

Arithos Designs
www.Arithos.com

A Premier DSP Design Consultancy and Training Company.




On Jun 25, 1:08 am, raj <rajesh.o...@gmail.com> wrote:
> Hai, > > I have written a unit step matlab code as follows: > > h=[0.21193952414828646 > 0.47183270983487557 > 0.47183270983487557 > 0.21193952414828646 > ]; > > step= zeros(4,1); > for i=1:4 > step(i) =1; > end; > > output = conv(h,step); > > output: > 0.211939524148286 > 0.683772233983162 > 1.155604943818038 > 1.367544467966324 > 1.155604943818038 > 0.683772233983162 > 0.211939524148286 > > The above step response is according to boundary conditions: > N+M-1 > > But using FDA tool i got only this: > > 0.211939524148286 > 0.683772233983162 > 1.155604943818038 > 1.367544467966324 > > The above step response is based on number of input samples = number > of o/p samples > > In both the cases u(n)={1,1,1,1} > > My objective is i wish to change my MATLAB code so that i should > achieve the same o/p as generated by FDAtool...or Is there way to > store the step responses values of FDAtool?pls suggest. > > regards, > raj
The Matlab filter function outputs the same number of samples as the input. Other than this, how is the data from the filter tool different from your data? Look at the help for filter. You can append trailing zeros to your data to flush the other values from filter in y or take them directly as zf. What makes you think [1 1 1 1] is a step response? Dale B. Dalrymple
hai,
What makes you think [1 1 1 1] is a step response?
I am defining the input step signal as u(n)=1; 0<n<4
                                                      0;otherwise


y = filter(b, a, x);
the above worked thanks...


for the output value 0.098765 i want to make as  .98765...for that i
tried the following

s=sprintf('%15.15f\n',output);
    a=regexprep(s,'^0*','');
 fprintf(outfile1, '%s\n', a);

The above change also not meeting my objective ..though i referred
the
doc..pls suggest where i am doing wrong?

regards,
raj


On Jun 25, 2:40&#4294967295;pm, dbd <d...@ieee.org> wrote:
> On Jun 25, 1:08 am, raj <rajesh.o...@gmail.com> wrote: > > > > > Hai, > > > I have written a unit step matlab code as follows: > > > h=[0.21193952414828646 > > 0.47183270983487557 > > 0.47183270983487557 > > 0.21193952414828646 > > ]; > > > step= zeros(4,1); > > &#4294967295; &#4294967295; &#4294967295; &#4294967295; for &#4294967295; &#4294967295; i=1:4 > > &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295;step(i) =1; > > &#4294967295; &#4294967295; &#4294967295; &#4294967295; end; > > > output = conv(h,step); > > > output: > > 0.211939524148286 > > 0.683772233983162 > > 1.155604943818038 > > 1.367544467966324 > > 1.155604943818038 > > 0.683772233983162 > > 0.211939524148286 > > > The above step response is according to boundary conditions: > > N+M-1 > > > But using &#4294967295;FDA tool i got only this: > > > 0.211939524148286 > > 0.683772233983162 > > 1.155604943818038 > > 1.367544467966324 > > > The above step response is based on number of input samples = number > > of o/p samples > > > In both the cases u(n)={1,1,1,1} > > > My objective is i wish to change my MATLAB code so that i should > > achieve the same o/p as generated by FDAtool...or Is there way to > > store the step responses values of FDAtool?pls suggest. > > > regards, > > raj > > The Matlab filter function outputs the same number of samples as the > input. Other than this, how is the data from the filter tool different > from your data? > > Look at the help for filter. You can append trailing zeros to your > data to flush the other values from filter in y or take them directly > as zf. > > What makes you think [1 1 1 1] is a step response? > > Dale B. Dalrymple
On Jun 25, 3:36 am, raj <rajesh.o...@gmail.com> wrote:

> hai, > What makes you think [1 1 1 1] is a step response? > I am defining the input step signal as u(n)=1; 0<n<4 > 0;otherwise > ...
Your response [1 1 1 1] contains no step. It could be a sample of a DC value. If you extend with zeros on both sides, it is a pulse, which is the scaled sum of two step responses, one rising and then one falling. Try comparing the results of filter() on these: 1) [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] 2) [0, 0, 0, 0, 0, 0, 0, 0, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1] 3) [0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0] The first is a positive step response, the second a negative step response and the third is your signal with actual zeros appended. Your signal is the sum of the first two signals. Dale B. Dalrymple
>On Jun 25, 3:36 am, raj <rajesh.o...@gmail.com> wrote: > >> hai, >> What makes you think [1 1 1 1] is a step response? >> I am defining the input step signal as u(n)=1; 0<n<4 >> 0;otherwise >> ... > >Your response [1 1 1 1] contains no step. It could be a sample of a DC >value. If you extend with zeros on both sides, it is a pulse, which is >the scaled sum of two step responses, one rising and then one falling. >Try comparing the results of filter() on these: > > 1) [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] > > 2) [0, 0, 0, 0, 0, 0, 0, 0, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1] > > 3) [0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0] > >The first is a positive step response, the second a negative step >response and the third is your signal with actual zeros appended. Your >signal is the sum of the first two signals. > >Dale B. Dalrymple > >
%%%%%% As the filter command gives same number of o/p bits as i/p and if want to see remaining bits, use [y state]=filter();
Your response [1 1 1 1] contains no step. It could be a sample of a DC
value.

Yes i agree with you ...but i am confused here since there are only
four value coefficients.

before doing filtering operation if the number of input
samples<coefficients zero pad the input sample till it equals
coefficients samples to avoid o/p truncation.

if the number of input sample > coefficients what should i do?

and also for the following code:
s=sprintf('%1.1f\n',output);
  a=regexprep(s,'^0*','');
  fprintf(outfile2, '%s\n', a);

It is doing the removal of zero job for the first value only..
output                  a
0.1                      .1
0.2                     0.2
0.3                     0.3
0.4                     0.4

How can i repeat this for others?what is the necessary change for
that?


regards,
raj

dbd wrote:

> On Jun 25, 3:36 am, raj <rajesh.o...@gmail.com> wrote: > > > hai, > > What makes you think [1 1 1 1] is a step response? > > I am defining the input step signal as u(n)=1; 0<n<4 > > 0;otherwise > > ... > > Your response [1 1 1 1] contains no step. It could be a sample of a DC > value. If you extend with zeros on both sides, it is a pulse, which is > the scaled sum of two step responses, one rising and then one falling. > Try comparing the results of filter() on these: > > 1) [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] > > 2) [0, 0, 0, 0, 0, 0, 0, 0, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1] > > 3) [0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0] > > The first is a positive step response, the second a negative step > response and the third is your signal with actual zeros appended. Your > signal is the sum of the first two signals. > > Dale B. Dalrymple
raj wrote:
> Your response [1 1 1 1] contains no step. It could be a sample of a DC > value. > > Yes i agree with you ...but i am confused here since there are only > four value coefficients.
Before going further, let's clear something up. Are you really saying that the number of samples to be filtered may not exceed the number of coefficients in the filter? Imagine filtering a half-hour-long symphony on a CD. Take it from there. ... Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
"Jerry Avins" <jya@ieee.org> wrote in message 
news:M_mdnU5ezfGBOv7VnZ2dnUVZ_jGdnZ2d@rcn.net...
> raj wrote: >> Your response [1 1 1 1] contains no step. It could be a sample of a DC >> value. >> >> Yes i agree with you ...but i am confused here since there are only >> four value coefficients. > > Before going further, let's clear something up. Are you really saying that > the number of samples to be filtered may not exceed the number of > coefficients in the filter? Imagine filtering a half-hour-long symphony on > a CD. Take it from there. > > ... > > Jerry > -- > Engineering is the art of making what you want from things you can get. > &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
In fact, maybe it is time to get back to basics. The phrase "unit step response" is commonly understood to mean the response of a system -- an FIR filter in this instance -- to a unit step function, where by "unit step function" is meant the signal u[n] where u[n] = 0 for n < 0 and u[n] = 1 for nonnegative values of n, viz., n = 0, 1, 2, ... The response y[n] of an FIR filter to u[n] consists of a transient followed by a steady-state output. Specifically, if the impulse response of the FIR filter is h[0], h[1], h[2], ... , h[m], and h[i] = 0 for i > m, then the unit step response of the FIR filter is y[0] = h[0] y[1] = h[0] + h[1] y[2] = h[0] + h[1] + h[2] ...... ....... y[m] = h[0] + h[1] + h[2] + .... + h[m] and y[i] = h[0] + h[1] + h[2] + .... + h[m] for all i > m. That is, the transient part of the response is y[0], y[1], ... y[m-1] and thereafter the FIR output has fixed value h[0] + h[1] + h[2] + .... + h[m]. The OP's FIR filter is h=[0.21193952414828646 0.47183270983487557 0.47183270983487557 0.21193952414828646 ]; Note that m = 3. His FDA tool gives him 0.211939524148286 0.683772233983162 1.155604943818038 1.367544467966324 which are the terms y[0], y[1], y[2], y[3] of the unit step response. Thereafter, the FIR output is necessarily y[4] = y[5] = ..... 1.367544467966324 forever and ever and so these values need not be computed or printed by the FDA tool. The OP's MATLAB code gives him the FIR response to the signal x[n] where x[1] = x[2] = x[3] = x[4] = 1 and x[i] = 0 otherwise. This response is z[0] = h[0] z[1] = h[0] + h[1] z[2] = h[0] + h[1] + h[2] z[3] = h[0] + h[1] + h[2] + h[3] z[4] = h[1] + h[2] + h[3] z[5] = h[2] + h[3] z[6] = h[3] and z[i] = 0 for i > 6. The response of the FIR filter to the unit step function u[n] is different from its response to the "rectangular pulse" signal x[n]. Should this difference puzzle the denizens of comp.dsp so much? --Dilip Sarwate
Dilip V. Sarwate wrote:
> "Jerry Avins" <jya@ieee.org> wrote in message > news:M_mdnU5ezfGBOv7VnZ2dnUVZ_jGdnZ2d@rcn.net... >> raj wrote: >>> Your response [1 1 1 1] contains no step. It could be a sample of a DC >>> value. >>> >>> Yes i agree with you ...but i am confused here since there are only >>> four value coefficients. >> Before going further, let's clear something up. Are you really saying that >> the number of samples to be filtered may not exceed the number of >> coefficients in the filter? Imagine filtering a half-hour-long symphony on >> a CD. Take it from there. >> >> ... >> >> Jerry >> -- >> Engineering is the art of making what you want from things you can get. >> &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295; > > In fact, maybe it is time to get back to basics. The phrase "unit step > response" > is commonly understood to mean the response of a system -- an FIR filter > in this instance -- to a unit step function, where by "unit step function" > is meant the signal u[n] where u[n] = 0 for n < 0 and u[n] = 1 for > nonnegative values of n, viz., n = 0, 1, 2, ... The response y[n] of an > FIR filter to u[n] consists of a transient followed by a steady-state > output. Specifically, if the impulse response of the FIR filter is h[0], > h[1], h[2], ... , h[m], and h[i] = 0 for i > m, then the unit step > response of the FIR filter is > > y[0] = h[0] > y[1] = h[0] + h[1] > y[2] = h[0] + h[1] + h[2] > ...... > ....... > y[m] = h[0] + h[1] + h[2] + .... + h[m]
...
> The response of the FIR filter to the unit step function u[n] is different > from its response to the "rectangular pulse" signal x[n]. Should this > difference puzzle the denizens of comp.dsp so much?
Of course you are right. I thought it wise to undertake the explication one step at a time. When a concept seems to have been fundamentally misunderstood, it is often vest to address one issue at a time. Is that too pompous? Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;