Solving a variable from a set of equations.

1 Ansicht (letzte 30 Tage)
Robert Roy
Robert Roy am 2 Jul. 2015
Kommentiert: Star Strider am 2 Jul. 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 Kommentar
John D'Errico
John D'Errico am 2 Jul. 2015
So use nlinfit. What is the problem? You apparently already know what function you wish to use.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Star Strider
Star Strider am 2 Jul. 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 Kommentare
Robert Roy
Robert Roy am 2 Jul. 2015
Bearbeitet: Robert Roy am 2 Jul. 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 am 2 Jul. 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Linear and Nonlinear Regression finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by