Solving a variable from a set of equations.

1 回表示 (過去 30 日間)
Robert Roy
Robert Roy 2015 年 7 月 2 日
コメント済み: Star Strider 2015 年 7 月 2 日
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 Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by