## Averaging several experiments with changing (maybe random) phases

When nonlinearities may be present, it is a good practice to make several multisine experiments with changing (random) phases in each experiment. In this case, varanal cannnot be used without special manipulations, since the changing phases cannot be brought to the same position.

There are two solutions to tackle this problem.

#### Correcting phases one by one

When generating the excitation signal, you have the phases of each sine. Let us denote the vector of phases in radians by phases. Here is a sample program for each experiment.
```%Do this for each experiment
tdati=tiddata(yi,ui,Ts);
tdati.frequencies=freqvect;
Fdati=tim2fou(tdati);
Fdati.output=exp(-j*phases).*Fdati.output;
Fdati.input=exp(-j*phases).*Fdati.input;
%Now the phases are not influenced by the excitation
%
Fdatall=merge(Fdat1,Fdat2,...); %Multiple experiments
Fdatall.synchronization='on'; %Tell varanal to simply average
Fdat=varanal(Fdatall); %This can be used by elis or by the GUI
```

#### Convert data to FRF

Another possibility is to convert the data to FRF = Y/U. By this, the Gaussian nature of the noise is somewhat violated (not much for good input SNR), and the variance of Y/U is approximated, but usually this is not a big problem.

This method works properly in fdident toolbox version 3.1b (21-Jun-2002 or later only) - if  fdtool version  returns something earlier, please update from the web, from index.html.

```%Do this for each experiment
tdati=tiddata(yi,ui,Ts);
tdati.frequencies=freqvect;
Fdati=tim2fou(tdati);
Fdatfrfi=stdtfm(Fdati);
%
Fdatall=merge(Fdatfrf1,Fdatfrf2,...); %Multiple experiments
Fdatall.synchronization='on'; %Tell varanal to simply average
Fdat=varanal(Fdatall); %This can be used by elis or by the GUI
```
*****************************