Solving a variable from a set of equations.

1 vue (au cours des 30 derniers jours)
Robert Roy
Robert Roy le 2 Juil 2015
Commenté : Star Strider le 2 Juil 2015
Hi there, I have got a code currently that's used to create a nlinfit from experimental results. I also have a code which can give me the simulation results. What I want to do is use the curve from experimental data and solve for a variable in the simulation results to give the same results.
  1 commentaire
John D'Errico
John D'Errico le 2 Juil 2015
So use nlinfit. What is the problem? You apparently already know what function you wish to use.

Connectez-vous pour commenter.

Réponse acceptée

Star Strider
Star Strider le 2 Juil 2015
It seems you want to know how to use the results of nlinfit to simulate your objective function. To do this, substitute the estimated parameters into your function to get the results.
For example:
f = @(b,x) b(1) + b(2).*exp(b(3).*x); % Objective Function
x = linspace(0, 10, 25); % Create Data
y = f([7; 5; -3], x) + 0.1*randn(size(x)); % Create Data
B = nlinfit(x, y, f, [1; 1; -1]); % Estimate Parameters
figure(1)
plot(x, y, 'bp') % Plot Data
hold on
plot(x, f(B,x), '-g') % Substitute Estimated Parameters, Plot
hold off
grid
  2 commentaires
Robert Roy
Robert Roy le 2 Juil 2015
Modifié(e) : Robert Roy le 2 Juil 2015
Yes that is what I want to do what I essentially have is:
% code
modelFun2 = @(c,x) (c(2)) - (x./ c(1)); % Experimental Function Results
d_p(1)=Variable
S= function of d_p(1) %Simulation results
modelFun = @(c,x) (c(2)) - (x./ c(1)); %Simulation Model
end
I want to solve for a value of d_p(1) that will give the same nlinfit model equation for the experimental and simulation.
Star Strider
Star Strider le 2 Juil 2015
‘I want to solve for a value of d_p(1) that will give the same nlinfit model equation for the experimental and simulation.’
I’m not sure what ‘d_p(1)’ is or where it fits in your function.
However, if you want to determine the optimal values of your parameters with respect to fitting your data, you already have, by using nlinfit. Unless you have (1) a model that exactly describes the process that created your data, and (2) absolutely no noise in your data, you will never be able to exactly reproduce your data. The parameters you got from nlinfit and the fit your function creates with them are the best you can hope for.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Linear and Nonlinear Regression dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by