필터 지우기
필터 지우기

finding fit parameters between two functions

조회 수: 5 (최근 30일)
Eli
Eli 2023년 12월 23일
댓글: Torsten 2023년 12월 24일
Hello
I have a script, where i have a simulation that creates a function.
On the other hand I have a measurement. They don't fit and I want to use fminsearch to try to find the variables that can make them fit.
The idea is to find the variables N_set , A_dir, A_seq and maybe some offset in time (x axis)and Const (y axis).
Would appriciate some help.
The simulation and data are presented. this is example of one specific value set, where we can see the don't have a very good overlap.
Would appriciate your help.
Thanks.
load('matlab1.mat')
untitled5()
Unrecognized function or variable 'time_average_data'.

Error in untitled5 (line 169)
hold on; plot(time_average_data,average_data_set-min(average_data_set),'LineWidth', 1.5)
  댓글 수: 3
Eli
Eli 2023년 12월 23일
편집: Eli 2023년 12월 23일
So I just played with the parameters by hand. that's why i need parameter optimization.
Without this, it's totally off so more precise fit will bring me closer to my real parameters. (will have many similar experiments so optimization should help a lot)
Image Analyst
Image Analyst 2023년 12월 23일
Is the function that gives a fit just a single mathematical formula? If so, what is it?

댓글을 달려면 로그인하십시오.

채택된 답변

Torsten
Torsten 2023년 12월 23일
편집: Torsten 2023년 12월 23일
Make a function that - given tau and the parameters you want to fit - returns I_m(tau).
Then look at the examples for "lsqcurvefit" to see how you can use this function as the "fun" in the call to the optimizer.
Use the parameters you fitted by hand as vector of initial values for the parameter vector.
  댓글 수: 8
Eli
Eli 2023년 12월 24일
편집: Eli 2023년 12월 24일
Perfect!
That solved it.
The name by the way is " FinDiffRelStep" instead of "FiniteDifferenceStepSize"
I used than (didn't find how to only set one variable X(5)) :
options = optimset('FinDiffRelStep', [sqrt(eps) sqrt(eps) sqrt(eps) sqrt(eps) 1e-2 sqrt(eps)]);
x = lsqcurvefit(@untitled5, x0, time_average_data, average_data_set,lb,ub,options);
And, it seems to start changing. thanks.
Torsten
Torsten 2023년 12월 24일
If you use "optimoptions" instead of "optimset", the name is "FiniteDifferenceStepSize".
Glad to hear that it seems to work now.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Model Predictive Control Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by