
Re: [Matlab Question] Converting H(s) to H(z) using derivative approximation?
Posted:
Oct 24, 2010 4:30 PM


On 10/24/2010 12:11 PM, frodonet wrote: > Hi Nasser, > > thanks for your help. > > Sorry i didn't post my workings before. Here is what i actually did in my matlab. > > 1) I found out the sroots by using the roots(p) command. > > 2) then i use the relationship for derivate approximation where z^1 = 1  sT. > > 3) So from s roots, i get the z roots and then i contruct the polynomial from zroots using the poly(A) command. > > 4) Then from the polynomial coefficients, i just use freqz to plot the magnitude vs freq response. > > Not sure it's 100% right, but when i plot it the shape is correct which is a low pass filter but the > magnitude might be a little off. > > After seeing your solution, i need to give it a try. > > But do you know that the relationship between s and z is as such : > > z^1 = 1  sT > > So when you have such relationship, does your method still holds?
Your method looks correct for first order derivative method.
The methods I know of are:
1. first order derivative approx: z=1/(1sT), requires very large sampling to work ok, good only for low pass filter design
2. higher order derivative approximations from (1). Do not know much about it.
3. impulse invariance: z=exp(sT), zeros do not get mapped correctly, only poles. Aliasing problems.
4. matchedz: factor H(s) into (ssz)/(ssp) form, where sz are the zeros of the numerator and sp are zeros of the denominator (ie. pols of H(s), then replace all the (ssp) by (1exp(sp*T) z^1) and replace all the (ssz) by (1exp(sz*T) z^1) to obtain H(z). Requires small T also, like (1)
5. bilinear transformation: z= (1+(T/2)*z) / (1(T/2)*z ) requires frequency wrapping, but is the best one of all, when in doubt use. no aliasing.
Now as far is which one is which in Matlab, I just had a look at help on c2d, and it says:
'zoh' Zeroorder hold on the inputs 'foh' Linear interpolation of inputs (triangle appx.) 'impulse' Impulseinvariant discretization 'tustin' Bilinear (Tustin) approximation. 'matched' Matched polezero method (for SISO systems only).
Clearly the last 3 we now know what they are, the description is clear.
We just need to figure if zoh or foh are the first first order derivative or not? I am not sure now without spending more time on it.
My guess is that 'foh' is the first order approximation. But a Matlab expert on these might have a better answer. It could be something completely different.
You can try your method and compare with Matlab's zoh or foh and see which gives the same result.
Use 'tustin', it is supposed to be the best method, this is the bilinear method.
Nasser

