Fittype with anonymous function of multiple parameters and variables
이전 댓글 표시
Dear Matlab users,
I'm new to Matlab so I apologize if the solution to my problem is obvious.
I want to do two fit in a row, the second fit taking as input two values calculated through the first fit.
I have been reading about the anonymous functions in order to give as input to the second fit two variables and not parameters to optimize, I don't know what I'm missing but it does not work...
My first fit :
data = readtable("SF.xlsx");
tab_0 = data(data.C == 0,:);
[xData, yData] = prepareCurveData( tab_0.Dose, tab_0.SF );
ft0 = fittype( 'exp(-(a*x+b*x*x))', 'independent', 'x', 'dependent', 'y' );
opts.StartPoint = [0.678735154857773 0.757740130578333];
[ModelFit0,fitresult0, gof0] = fit( xData, yData, ft0, opts );
Now I want my second fit to optimize parameter gamma according to variables x and y and formula 'exp(-(alpha*x+beta*x*x))*exp(-(gamma*x*y))' with
alpha = ModelFit0.a;
beta = ModelFit0.b;
I tried
alpha = ModelFit0.a;
beta = ModelFit0.b;
ft0 = fittype( @(gamma,x,y) exp(-(alpha*x+beta*x*x))*exp(-(gamma*x*y)), 'independent', 'x', 'dependent', 'y' );
but it seems to be a problem between coefficients and parameters...
Has someone an idea how to solve this issue?
Many thanks for your help!
댓글 수: 2
Matt J
2023년 7월 3일
You haven't shown us the result of running the code, so we don't know what problem you're seeing.
Please provide copy-pastes of any error messages and attach the .xlsx input file. Ideally, you would just run the code for us here, using the forum's Matlab engine.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Linear Predictive Coding에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
