Main Content

Harmonic Analysis of Transfer Function Output

This example finds closed-form solutions for the coefficients of frequencies in an output signal. The output signal results from passing an input through an analytical nonlinear transfer function.

This example uses the following Symbolic Math Toolbox™ capabilities:

Motivation

To motivate the solution, we take a simple element from circuit theory: an ideal diode (in forward bias operation). The current, I, is the output that depends exponentially on the input, V. Diodes have found use in creating devices such as mixers and amplifiers where understanding the harmonic structure of the output can be useful in characterizing the device and meeting design specifications.

syms Is V Vo real;
I = Is*(exp(V/Vo) - 1)
I = IseV/Vo-1

If V is a linear combination of 2 signals at frequencies LO and RF, the nonlinear transfer function will mix LO and RF to create output with content at combinatorial harmonic frequency combinations: freqs = {LO, 2LO, RF, 2RF, LO-RF, LO-2RF,...}.

The objective of this example is to determine the coefficients of freqs in the output.

Define Input Signal

The input signal is a linear combination of two cosine signals.

syms c1 c2 t LO RF real;
input = c1*cos(LO*t) + c2*cos(RF*t)
input = c1cos(LOt)+c2cos(RFt)

Define Space of Harmonic Frequency Combinations

Below, harmCombinations is a combinatorial combination of the integer multiples of the input frequencies LO and RF. We restrict the space of interest defined by 3 harmonics each in the LO and RF directions.

n = 3;
harmCombinations = [kron((0:n)',ones(n*2+1,1)),repmat((-n:n)',n+1,1)];
freqs = harmCombinations*[LO;RF];

The first n frequencies are just the negative harmonic frequencies and are therefore redundant considering that the input signal is real.

freqs = freqs(n+1:end)
freqs = 

(0RF2RF3RFLO-3RFLO-2RFLO-RFLOLO+RFLO+2RFLO+3RF2LO-3RF2LO-2RF2LO-RF2LO2LO+RF2LO+2RF2LO+3RF3LO-3RF3LO-2RF3LO-RF3LO3LO+RF3LO+2RF3LO+3RF)

Taylor Expansion

To cover the frequency spectrum of interest, a Taylor series of order four for I(V) is sufficient.

s = taylor(I, V, 'Order', 4)
s = 

IsV22Vo2+IsV36Vo3+IsVVo

Use an input signal combination of the LO and RF frequencies and express f in terms of cos(LO*t) and cos(RF*t).

f0 = subs(s, V, input);
f = expand(f0)
f = 

Isc12σ22Vo2+Isc13cos(LOt)36Vo3+Isc22σ12Vo2+Isc23cos(RFt)36Vo3+Isc1cos(LOt)Vo+Isc2cos(RFt)Vo+Isc1c2cos(LOt)cos(RFt)Vo2+Isc1c22cos(LOt)σ12Vo3+Isc12c2σ2cos(RFt)2Vo3where  σ1=cos(RFt)2  σ2=cos(LOt)2

Rewrite f in terms of single powers of cosines.

f = combine(f, 'sincos')
f = 

Isc124Vo2+Isc224Vo2+Isc1cos(LOt)Vo+Isc2cos(RFt)Vo+Isc12cos(2LOt)4Vo2+Isc13cos(LOt)8Vo3+Isc13cos(3LOt)24Vo3+Isc22cos(2RFt)4Vo2+Isc23cos(RFt)8Vo3+Isc23cos(3RFt)24Vo3+Isc1c22cos(LOt)4Vo3+Isc12c2cos(RFt)4Vo3+Isc1c2cos(LOt+RFt)2Vo2+Isc1c2cos(LOt-RFt)2Vo2+Isc1c22cos(LOt-2RFt)8Vo3+Isc1c22cos(LOt+2RFt)8Vo3+Isc12c2cos(2LOt+RFt)8Vo3+Isc12c2cos(2LOt-RFt)8Vo3

Extract and Display Coefficients

Get the non-constant i.e. non-DC harmonic frequency terms of the form cos(freq*t).

cosFreqs = cos(expand(freqs*t));
terms = collect(setdiff(cosFreqs', sym(1)));

Extract the coefficients for all harmonic frequency terms including DC.

newvars = sym('x', [1,numel(terms)]);
[cx, newvarsx] = coeffs(subs(f,terms,newvars), newvars);
tx = sym(zeros(1,numel(cx)));
for k=1:numel(newvarsx)
    if newvarsx(k) ~= 1
        tx(k) = terms(newvars == newvarsx(k));
    else
        tx(k) = newvarsx(k);
    end
end
cx = simplify(cx);

Display the coefficients using table, T. Use cosFreqs as a row identifier.

cosFreqs = arrayfun(@char,cosFreqs,'UniformOutput',false);
Frequencies = arrayfun(@char,freqs,'UniformOutput',false);
Coefficients = num2cell(zeros(size(freqs)));
T = table(Frequencies,Coefficients,'RowNames',cosFreqs);

Assign cx to the appropriate rows of T corresponding to the cosine terms of tx.

nonzeroCosFreqs = arrayfun(@char,tx,'UniformOutput',false).';
T(nonzeroCosFreqs,'Coefficients') = arrayfun(@char,cx,'UniformOutput',false).';

Now, remove row names as they are redundant.

T.Properties.RowNames = {};

Observe that the expressions for the terms are symmetric in LO and RF.

T
T=25×2 table
      Frequencies                      Coefficients                 
    _______________    _____________________________________________

    {'0'          }    {'(Is*(c1^2 + c2^2))/(4*Vo^2)'              }
    {'RF'         }    {'(Is*c2*(8*Vo^2 + 2*c1^2 + c2^2))/(8*Vo^3)'}
    {'2*RF'       }    {'(Is*c2^2)/(4*Vo^2)'                       }
    {'3*RF'       }    {'(Is*c2^3)/(24*Vo^3)'                      }
    {'LO - 3*RF'  }    {[                                        0]}
    {'LO - 2*RF'  }    {'(Is*c1*c2^2)/(8*Vo^3)'                    }
    {'LO - RF'    }    {'(Is*c1*c2)/(2*Vo^2)'                      }
    {'LO'         }    {'(Is*c1*(8*Vo^2 + c1^2 + 2*c2^2))/(8*Vo^3)'}
    {'LO + RF'    }    {'(Is*c1*c2)/(2*Vo^2)'                      }
    {'LO + 2*RF'  }    {'(Is*c1*c2^2)/(8*Vo^3)'                    }
    {'LO + 3*RF'  }    {[                                        0]}
    {'2*LO - 3*RF'}    {[                                        0]}
    {'2*LO - 2*RF'}    {[                                        0]}
    {'2*LO - RF'  }    {'(Is*c1^2*c2)/(8*Vo^3)'                    }
    {'2*LO'       }    {'(Is*c1^2)/(4*Vo^2)'                       }
    {'2*LO + RF'  }    {'(Is*c1^2*c2)/(8*Vo^3)'                    }
      ⋮

Verify Coefficients

As shown below, the output waveform is reconstructed from the coefficients and has an exact match with the output.

simplify(f0 - (dot(tx,cx)))
ans = 0

Plot Nonlinear Transfer

The following shows the particular nonlinear transfer function analyzed above, in the time and frequency domains, for certain values of the frequencies and voltage ratios. First, extract the data.

sample_values = struct('c1',0.4,'c2',1,'LO',800,'RF',13600,'Vo',1,'Is',1);
sample_input = subs(input,sample_values)
sample_input = 

2cos(800t)5+cos(13600t)

sample_output = subs(f,sample_values)
sample_output = 

127cos(800t)250+cos(1600t)25+cos(2400t)375+cos(12000t)50+cos(12800t)5+233cos(13600t)200+cos(14400t)5+cos(15200t)50+cos(26400t)20+cos(27200t)4+cos(28000t)20+cos(40800t)24+29100

sample_freqs = zeros(size(tx));
for k=1:numel(tx)
    cosTerm = subs(tx(k),sample_values);
    freq = simplify(acos(cosTerm),'IgnoreAnalyticConstraints',true)/t;
    sample_freqs(k) = double(freq);
end
sample_heights = double(subs(cx,sample_values));

Then, use fplot and stem to plot the functions and their harmonic frequencies.

subplot(2,2,1);
fplot(sample_input,[0,0.01])
title Input
subplot(2,2,3);
stem([sample_values.LO, sample_values.RF],[sample_values.c1,sample_values.c2]);
title 'Input Frequencies'

subplot(2,2,2);
fplot(sample_output,[0,0.01])
title Output
subplot(2,2,4);
stem(sample_freqs,sample_heights)
title 'Output Frequencies'

Figure contains 4 axes objects. Axes object 1 with title Input contains an object of type functionline. Axes object 2 with title Input Frequencies contains an object of type stem. Axes object 3 with title Output contains an object of type functionline. Axes object 4 with title Output Frequencies contains an object of type stem.