필터 지우기
필터 지우기

How can I fit an double exponential curve?

조회 수: 21 (최근 30일)
Amanda Botelho Amaral
Amanda Botelho Amaral 2021년 12월 18일
댓글: Amanda Botelho Amaral 2021년 12월 20일
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
Mathieu NOE
Mathieu NOE 2021년 12월 20일
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 2021년 12월 20일
"use only the decaying portion of the signal for adjustment"
That's just what I don't think! Thank you very much!

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2013a

Community Treasure Hunt

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

Start Hunting!

Translated by