# Find Zeros, Poles, and Gains for CTLE from Transfer Function

This example shows how to configure the Specification parameter `GPZ Matrix` of a CTLE in the SerDes Designer app to use zeros, poles, and gains output by the `zpk` function, given poles and residues output by the `rational` function. You can reformat the set of zeros, poles, and gains output by the `zpk` function to use as a `GPZ matrix` in a CTLE block.

### Import Transfer Function

Import a .csv file containing a transfer function using the `readmatrix` function.

```ctle_transfunc = readmatrix('ctle_transfer_function.csv','Range','A7:E775'); freq = ctle_transfunc(:,1); ri = ctle_transfunc(:,4:end); ```

### Convert Transfer Function to Complex Form

To prepare data for use by the `rational` function, convert the real numbers from the transfer function to complex numbers using the `complex` function.

`data = complex(ri(:,1:2:end),ri(:,2:2:end));`

### Find Rational of Transfer Function

You can use the `rational` function to find the best fit to the transfer function. The `rational` function performs iterations to identify a fit with the lowest error. It is important to set the argument `TendsToZero` to `true` to add a pole so that the fit tends to zero as S approaches infinity. This meets the requirement to have one more pole than the number of zeros in the GPZ matrix.

`bestfit = rational(freq,data,'Tolerance',-40,'TendsToZero',true,'MaxPoles',8,'Display','on');`
```nSurrogate=1; reduced to 100.0% min achievable error=-Inf Region 1 of 1 init: np=0 errdb=0 Region 1 of 1: np=0 errdb=-3.04769 Region 1 of 1: np=2 errdb=-37.9389 Region 1 of 1: np=4 errdb=-122.215 final: np=4 errdb=-123.386 ```

### Convert to Zeros, Poles, Gains from Poles and Residues

The `rational` function returns poles and residues, but you need to convert these into zeros, poles and gains for a CTLE block. The CTLE can be configured to use Specification parameter `GPZ Matrix` where the units for gains, poles and zeros are dB, Hz, and Hz, respectively.

```[z,p,~,dcgain]=zpk(bestfit); gpz(1,1) = 20*log10(dcgain); % Convert to dB gpz(1,2:2:length(p)*2) = p/(2*pi); % Convert to Hz gpz(1,3:2:length(z)*2+1) = z/(2*pi); % Convert to Hz ```

### Configure CTLE Block in SerDes Designer

Launch the SerDes Designer app. Place a CTLE block after the analog model of the receiver. Select the CTLE and from the Block Parameters pane, set the Specification parameter to `GPZ Matrix`. Then copy the value of the `gpz` variable and paste it to the Gain pole zero matrix parameter, or type the name of the variable `gpz`. ### Correlate Pulse Response in SerDes Designer to IBIS-AMI Simulation

In the SerDes Designer app, plot the CTLE Transfer Function and Pulse Response from the Add Plots button. Then click the Export > Make IBIS AMI Model for SerDes System button. The IBIS-AMI model may be loaded into an appropriate EDA tool to plot the Pulse Response from the model. For correlation purposes, you can compare the plots for Pulse Response from the SerDes Designer app and the EDA tool. 