How can I fit an double exponential curve?

9 views (last 30 days)
Hi! I have a problem fitting a curve. I have two curves, one voltage and the other current, and I need the Z=V/I impedance. What I need to do is: Find the fit for the voltage curve. And with the new fit curve I found new impedance.
I made a code that I got a good fit of the curve, however, when plotting the new impedance it doesn't come out anything similar to the "original" (curve without adjustments).
can anybody help me?
Here is my code and data.
load('500_CONSTANTE_2u_V.MAT');
load('500_CONSTANTE_2u_C.MAT');
load('t.MAt');
t=t(2:200000);
%Impedancia
Z_Trad_Primeira_500=tensao_at_500./corrente_at_500;
figure(1)
plot(t*10^3,Z_Trad_Primeira_500,'r.');hold on;
%FIT
fcn1 = @(b,t) b(1).*exp(b(2).*t) + b(3).*exp(b(4).*t);
[f1, fval] = fminsearch (@ (b) norm (tensao_at_500 - fcn1 (b, t)), [1; -1; -1; -1]);
figure(2)
plot(t, tensao_at_500, 'p')
hold on
plot(t, fcn1(f1,t), '-')
hold off
grid
%new Z
Znew=fcn1(f1,t)./corrente_at_500;
figure(5)
plot(t*10^3,Z_Trad_Primeira_500,'r.');hold on;
plot(t*10^3,Znew ,'g--');hold on;
  16 Comments
Mathieu NOE
Mathieu NOE on 20 Dec 2021
hello Amanda
welcome back
as far as I understandthe publication you are refering to, the attempt is to do a simple two parameters exponential fit once for the voltage signal, one for the current signal
this is done here :
load('tensao_at_500.MAT');
load('corrente_at_500.MAT');
load('t.MAt');
figure(1)
plot(t,tensao_at_500,'b',t,corrente_at_500,'r');
title(' Voltage and current');
xlabel('time (s)');
ylabel('Amplitude');
% FIT voltage signal
% use only decaying portion of signal for the fit
[val,indm] = max(tensao_at_500);
tensao_fit = tensao_at_500(indm:end);
t_fit = t(indm:end);
fcn1 = @(b,t) b(1).*exp(b(2).*t);
[f1, fval] = fminsearch (@ (b) norm (tensao_fit - fcn1 (b, t_fit)), [val; -1e3;]);
figure(2)
plot(t, tensao_at_500, '*',t_fit, fcn1(f1,t_fit), '-')
title(' Voltage');
legend('voltage','exp fit');
xlabel('time (s)');
ylabel('Amplitude');
grid on
% FIT current signal
% use only decaying portion of signal for the fit
[val,indm] = max(corrente_at_500);
corrente_fit = corrente_at_500(indm:end);
t_fit = t(indm:end);
fcn2 = @(b,t) b(1).*exp(b(2).*t);
[f2, fval] = fminsearch (@ (b) norm (corrente_fit - fcn2 (b, t_fit)), [val; -1e3;]);
figure(3)
plot(t, corrente_at_500, '*',t_fit, fcn2(f2,t_fit), '-')
title(' Current');
legend('current','exp fit');
xlabel('time (s)');
ylabel('Amplitude');
grid on
Amanda Botelho Amaral
Amanda Botelho Amaral on 20 Dec 2021
"use only the decaying portion of the signal for adjustment"
That's just what I don't think! Thank you very much!

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2013a

Community Treasure Hunt

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

Start Hunting!