Solving a variable from a set of equations.

1 次查看(过去 30 天)
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 个评论
John D'Errico
John D'Errico 2015-7-2
So use nlinfit. What is the problem? You apparently already know what function you wish to use.

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2015-7-2
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 个评论
Robert Roy
Robert Roy 2015-7-2
编辑:Robert Roy 2015-7-2
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 2015-7-2
‘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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by