File Exchange

image thumbnail

Zfit

version 1.2.0.0 (8.57 KB) by Jean-Luc Dellis
ZFIT is a function which can PLOT, SIMULATE and FIT impedance data

33 Downloads

Updated 19 May 2010

View License

% Zfit(data)
Plots the impedance DATA which has to be a 3-columns wise matrix [FREQ, RealZEXP, ImagZEXP]. Impedance, admittance, capacitance and modulus representations in the complex plane are then pushbutton obtainable.
%
The others usages are described in the help lines with examples too...

Comments and Ratings (34)

Bonjour Bruno. Thanks you for your kind message.
I am very happy if some colleagues improve the code but I had no news from Jacopo since his 2016 coments. Yes indeed he was considering that "no bounds" would give better results. In my opinion, to get BETTER or not better results depends on the data and on the model (presence or not of small Z values, presence or not of CPE, ... which may have heavy influence on the fit process) . However it is expectable to get DIFFERENT results because to set bounds will mathematically change the f(p) target and the fit may converge to a different solution especially if the new target f(p) landscape is complex (has many local minima).
About the CPE, if the data is enough hum ... regular, in other words if the model is right, then I think it is not necessary to use bounds for the CPE exponent, it would be sufisient to furnish starting values in the [0 1] interval.
I didnt study these features ... Best Regards, Jean-Luc

Bruno Melo

Thank you so much Jean Luc.

Very nice code. I enjoyed the GUI version but this one is perfect for anyone who is comfortable with matlab. I was wondering if you were able to see the suggestions Jacopo Remondina provided. Was he considering that the fit was better if no bound restrictions were given as input? I am getting good results by just restricting some obvious variables such as the n power (N_Cpe) between 0 and 1 in the CPE elements. I also compared some fit results (made with Zfit) to other software such as Zview and got a good agreement. Have you made this study or published some article with this type of comparation by any means?

Thank you once again for providing us this code.

Bonjour John,
* The Khi2 definition is given in the ZfitGUI manual : https://drive.google.com/open?id=1_zryTSEnynGd_7FsXxFLj9H7J-gPqEWz. Dowload the manual, then open it with Word to read it properly (some formulae may disappear with other viewers; I will correct that soon).
* Fval from Zfit is the same : fval=Khi2, but only if the weigthing method is left as default : proportionnal. Otherwise, Fval is the value of the minimized function (which is the difference Ztheo versus Zexp) at the solution as stated in the fminsearch Matlab definition. Once again, some details which can help are given in the ZfitGUI manual.

Best regards,
Jean-Luc

John Aggas

Hi Dr. Dellis,

Thank you kindly for uploading this file - it works wonderfully. I see you have commented earlier that the FVAL is a measure of goodness of fit. I have a question with regard to that:

-Is there some mathematical relationship between FVAL and CHI^2? (I see that in ZfitGUI you calculate the CHI2 - we would like to calculate the CHI2 in the Zfit file).

Thank you!

To Allison : no sorry, these kind of optimizers must start with initial guesses. You may find them by analysis of the targeted data using "ZfitGUI", his manual and his tutorial also share in the file exchange Mathworks site. Regards, Jean-Luc

Is there a way to run this code and fit to circuit without inputting starting circuit parameters? The way I am trying to use this code - I may not know or have a good guess as to what to make the starting parameters.

Thanks!

Hi Allison. Please have a look on the help lines. The syntax is "[pbest,zbest,fval,exitflag,output]=Zfit(varargin)" where FVAL is a measure of the goodness of fit. Regards.

Matthew Li

Hi!
I get a wrong circuit simulation for series combination: for example the following code to generate the ZdB plot of a series RC

%frequencies definition

X=logspace(2,6,1000);
X=transpose(X);

%circuit parameter definition, series combination of R & C
C1=1e-6;
R1=50;

circuit_values=[C1,R1];
circuit_model='s(C1,R1)';

%Zfit eval

[fittedparam,FittedZ]=Zfit(X,'z',circuit_model,circuit_values);

%plotting the Zdb in semilog plot

figure;
semilogx(transpose(X),mag2db((abs(FittedZ(:,1)+FittedZ(:,2)))))

this code gives me
1) a fully imaginary impedance (which is not correct)
2) the module plotted has a notch, like series LC resonance (which doesn't make sense).

What am I missing?
thanks
Giuseppe

siva kumar

Hi,
Thanks a lot to Jean-Luc Dellis for providing this software to all. It will be much more helpful to the research scholars like me.
Could any one please explain, how to install this software in lab-tap. I downloaded this Zfit software, but i could not install it in my laptab. It would be highly helpful for my research work, if i could use this EIS fit software.

Regards
Siva

Sobi Thomas

Very useful and helpful

Bonjour Jacopo, I just have received today the notification of your coments.
To answer your first coment, I think it could come from the starting values which must close the best ones when using CPE. Another hint is to try the "fitNP" string (fit Not Proportionnal). I mean a fit could appear badly completed when estimated by eyes on the Z spectrum when it is good when checking the sum (error(i)/Z(i)) given by the output parameter fval.
About your second and interressing coment, I would like to get the data and the modified code... in order to check by myself.
Amicalement

update for my previous post:
I modify a bit more your code, turning the function "fminsearchbnd" to "fminsearch" (creating a new function "curfitNoBound") if no bounds are provided to Zfit and now the fit is much better (actualy better then in EIS Spectrum Analyzer), so I suggest to avoid parameter transformation if possible

First of all, thanks for this program, it's gonna really help me.
Second: I think that I managed to improve your function so now p() and s() can work with any number of parameters (maybe not 0, but a check is easy to implement);
Third I have a question for you: I tried to fit a complex circuit: s(R1,s(p(E2,R1),p(E2,R1))) with some data, but I'he got a fit that was worste then the input parameters (obtained via EIS software analyzer and entered in your program with 3 significant digit). Any idea why?

Mengfei Lyu

how can i download it

Really useful tool, thanks!


Hello,
Thank you very much for this function

Matthew Li

Hello,
Thank you very much for this function.
Did the world a big favor.
I was just wondering if it possible to easily obtain some sort of fitting statistic for each fitted parameter or just the whole fit in general.

Thank you very much!

Kamal R.

Thank You, J. Dellis. It worked and ZfitGUI is too good, Working great ;)

Dear Kamal.
1/ I tried your string and there was no error. I think the limit in the amount of elements is higher. So there is no problem to simulate data.
2/ Fitting experimental data with long strings will be an other task and you would beware of overparametrization (too many elements) leading to some parameter to have nonsensed values.
3/ I tried your string on some data and get the minimizer failed at the first try. As said in the help, I retried with the returned "pbest" as initial parameters and get the convergence. To end, I prompt you to use the "ZfitGUI" function which eases the data weigthing. Best regards.

Kamal R.

Such a wonderful code.

I am trying for this string s(R1,p(C1,s(R1,p(C1,s(R1,p(R1,s(R1,C1))))))) , it doesn't work with more than 7 elements for the string ?

Thank you Jean-Luc, I wasn't aware that nesting is possible.I tried it and works perfectly!
This makes the code even more beautiful ;)

Bonjour Walter.
As the operators "s" and "p" require exactly 2 arguments s(a,b) and p(c,d), the code you writen : s(p(R1,C1),p(R1,C1),p(R1,C1))
is not correct and would be : s(s(p(R1,C1),p(R1,C1)),p(R1,C1))
Hoping that will help,
Regards

I noticed that s(p(R1,C1),p(R1,C1),p(R1,C1)) is not accepted so i expanded the parser with a 'c' (from 'c'hain ;) at the 's' postion and added the c function accepting 3 pararmeters. Maybe the 's' function can be modified using overloading accepting more arguments?
Beautiful code btw!

Chen

Really thank you for such a wonderful work. it is very helpful for processing a large amount of EIS data.

Brunilda

Chen,

The operators s and p must have stricly 2 arguments. The operator s in the circuit string
's(R1,p(R1,E2),p(R1,E2),E2)'
has 4 arguments. Maybe you wanted :
's(s(R1,p(R1,E2)),s(p(R1,E2),E2))' ?

Chen

Great work!

When I am trying more complicated string like 's(R1,p(R1,E2),p(R1,E2),E2)', the programe seems not work?

Thank You !
For the reference, i suppose the author's name and the link to this page are sufficient.

J Rey

Excellent software, thanks. What should I make the reference to if writing a Journal Paper?

A GUI is now available, please see ZfitGUI :

http://www.mathworks.com/matlabcentral/fileexchange/26386-zfitguivarargin-fits-impedance-data

but still for MATLAB users because it is mandatory to write the fitting function. However, if no fitting is needed, checking the Z, Y, C or the Modulus spectra is easy...

Amit Kenny

Working just grate. Simple for operation by MATLAB user, but a GUI is needed for others. Very fast, and really converge to the data (not as the commercial programs which come with EIS systems).

Updates

1.2.0.0

the way circuit is entered has been modified to ease the use

MATLAB Release Compatibility
Created with R14
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: fminsearchbnd, fminsearchcon