fit non-linear scatter
Mostrar comentarios más antiguos
Hi
I have a bunch of scatters that I am trying to get a trend line for:
Plot = figure;
PV_KL = axes('Parent',Plot);
hold(PV_KL,'all');
scatter(U1, I1,'r','filled');
hold on
scatter(U2, I2,'b','filled');
U = linspace(0,1000,5000);
Poly1 = polyfit(U1,I1,5);
Poly2 = polyfit(U2,I2,5);
Trend1 = polyval(Poly1,U);
Trend2 = polyval(Poly2,U);
hold on
plot(U,Trend1,'k','LineWidth',1.5);
hold on
plot(U,Trend2,'k','LineWidth',1.5);
xlim([0 max(U1)+100]);
ylim([0 max(I1)+100]);
grid;
The polynomial order "5" in polyfit() gives me the best trend line so far, but the scatters actually represent measured logarithmic and exponential functions and not polynomials, so my trend lines are not quite right. Is there another function like polyfit() that I can use for logarithmic / exponential scatters? If so, how would you use it in my code?
Thanks in advance for any help!
I found the function
nlinfit()
which I suppose should work. But I am having trouble understanding how to use it (the fourth parameter). I am trying to get a fit for I over U according to the function
I = I_0 - exp(U/U_T)-1)
U is the variable on the x-axis and I on the y-axis.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Linear and Nonlinear Regression en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!