0

I would like to know can anyone tell me how to implement transfer function a1s+a2/(b1s+b2) using Matlab meaning with for loop in the discrete form not using tf([a1 a2],[b1 b2]). For example if I want to implement a1/s I know I would do something like:

value(n)=value(n-1)+a1*fx*Ts;

where Ts is sampling frequency and fx is the function that needs to be integrated. for the a3*s I would do following:

output=value(n)-lastvalue(n);
   lastvalue(n)=value(n);

But I am wondering how may I implement the generic (a1*s+a2)/(b1*s+b2)

Thanks

justin
  • 173
  • 2
  • 3
  • 11

1 Answers1

0

First, agree on how you want to transform from s domain to z domain (discrete). Using bilinear transformation, Substitute s with

2/T * (z-1)/(z+1). 

This is bilinear transformation. Solve the equation and divide by the highest order of z. For z^-n, that is the previous "n" sample.

Makketronix
  • 1,389
  • 1
  • 11
  • 31
  • Thanks I knew about bilinear transformation however here T is sampling frequency right? how do you choose it ? because it seems loop to calculate the values iteratively should be multiplied by 2/T each time and this clearly changes the answer. – justin Jul 13 '16 at 02:21
  • Also what do you do about derivative term since it is depend on initial condition as well – justin Jul 13 '16 at 18:12