How to Linearize and Fit Data Points in MATLAB?

Click For Summary
SUMMARY

This discussion focuses on linearizing and fitting data points in MATLAB using two specific functions: an exponential function, f(x)=CeAx, and a hyperbolic function, f(x)=1/(Ax+B). The participants discuss the transformation of variables, specifically using Y=ln(y) for the exponential function and Y=1/y for the hyperbolic function, to facilitate linear regression. The provided MATLAB code for polynomial fitting is noted, but participants express confusion regarding its application to the specific problem set.

PREREQUISITES
  • Understanding of least-squares curve fitting
  • Familiarity with MATLAB programming
  • Knowledge of logarithmic transformations
  • Basic concepts of polynomial regression
NEXT STEPS
  • Implement MATLAB code for linearizing data using Y=ln(y) for the exponential model
  • Develop MATLAB code for linearizing data using Y=1/y for the hyperbolic model
  • Compare the goodness of fit for both models using MATLAB's fit functions
  • Explore MATLAB's curve fitting toolbox for advanced fitting techniques
USEFUL FOR

Students and researchers in mathematics, data analysis, or engineering who are working on curve fitting and data modeling in MATLAB.

hunter55
Messages
3
Reaction score
0

Homework Statement


For the given set of data, find the least-square curve:
A) f(x)=Ce^Ax, by using the change of variable X=x, Y=ln(y), and C=e^B to linearize the data points.

B) f(x) = 1/(Ax+B), by using the change of variable X=x and Y = 1/y to linearize the data points.

x : [ -1 0 1 2 3]
y : [ 6.62 3.94 2.17 1.35 0.89]

I need the MATLAB code on how to do these 2 problems I am confused and which curve gives a better fit. ??


Homework Equations



This is the only code i know but idk how to do it with the question they are asking i need to pertain it to that

function C = poly(X,Y,M)
n=length(X);
B=zeros(1:M+1);
F=zeros(n,M+1);
for k=1:M+1
F(:,k)=X'.^(k-1);
end
A=F'*F;
B=F'*Y';
C=A\B;
C=flipud(C);


The Attempt at a Solution



These are the coefficients:
-0.0458x^3
0.5225x^2
-2.1567x
3.9040

I am confused with what the question is asking i know I am suppose to have a ans for part A and B
 
Physics news on Phys.org
Think about what a change of variable is, then figure out how to apply that to the data.

Aka, when you make a substitution for y=ln(y), that just means you take your y list, and just take the ln of that. That now because the new measurement for what used to be the y-axis.

Does that make sense?
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
Replies
2
Views
1K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K