Hi,
I have data(xdata,ydata) and want to fit a model with the data. The model is a generic one y=k/x, k is constant according to the shape of the data points. My questions are: 1. How can I know the precise form of the model? 2. After using lsqcurvefit, I get the constant. How can I get the equation itself to predict new y from new x.
Here is my data: xdata:[2;10;20;30;40;50;60;70;80;90;99.598] ydata: [98913.08;19922.26;10046.06;6751.64;5107.10;4116.99;3457.18;2988.11;2637.81;2358.34;2147.66]
Thanks in advance

 Réponse acceptée

Star Strider
Star Strider le 31 Jan 2018

0 votes

Do this:
xdata = [2;10;20;30;40;50;60;70;80;90;99.598];
ydata = [98913.08;19922.26;10046.06;6751.64;5107.10;4116.99;3457.18;2988.11;2637.81;2358.34;2147.66];
eqn = @(k,x) k./x; % Define Objective Function
B = lsqcurvefit(eqn, 1, xdata, ydata); % Estimate Parameter
xv = linspace(min(xdata), max(xdata)); % Create New ‘x’ Vector
yv = eqn(B,xv); % Use ‘B’ And ‘xv’ In ‘eqn’ TO Calculate ‘yv’
figure
plot(xdata, ydata, 'pg')
hold on
plot(xv, yv, '-r')
hold off
grid

2 commentaires

Abhay Athaley
Abhay Athaley le 31 Jan 2018
Thank you so much for the answer.
Star Strider
Star Strider le 31 Jan 2018
As always, my pleasure.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with Curve Fitting Toolbox dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by