Extracting only real parameter values using 'lsqcurvefit' or 'fminsearch'

2 views (last 30 days)
Hi, I am trying to fit the impedance of a circuit model to one generated from experiment. I can define the circuit model consisting of R,L,C. From the fitted impedance curves, I then want to extract the parameter values of R,L,C. My problem is the values generated are complex numbers. I want only real R,L, C values to be generated. Any suggestions?
I tried writing a code like this:
x0 = [Rm Lm Cm C_0 Rc Cc];
opts = optimset('Algorithm', 'levenberg-marquardt','Display', 'off','MaxIter',1e5, 'DiffMinChange', 1e-10, 'MaxFunEvals',1e5,'TolFun',1E-20,'TolX',1E-10); [ n, resnorm, residual, exitflag] = lsqcurvefit(@fun_complex,x0,w,ydata,[],[],opts);
where, function reZ = fun_complex(x,w)
% Rx = x(1); % Lx = x(2); % Cx = x(3); % C0 = x(4); x2 = x(2)/1e6; x3 = x(3)/1e12; x4 = x(4)/1e12;
Zmb = x(1) + j.*w.*x2+ 1./(j*w*x3); Zelec = 1./(j*w*x4);
Ymb = 1./Zmb; Yelec = 1./Zelec; Yx = Ymb + Yelec;
Z = 1./Yx;
reZ = Z; end

Answers (0)

Categories

Find more on Multicore Processor Targets in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!