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 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