Surface fit to determine the coefficients of a hypothetical equation
2 次查看(过去 30 天)
显示 更早的评论
Dear all! As is mentioned in the title, I have to perform a surface fit to figure out coefficients of an analytical model. The equation describing the model in Matlab syntax is shown as follows:
JordanMdl=@(K,B,f) K(1).*(f./f0).*(B./B0).^2+K(2).*(f./f0).^2.*(B./B0).^2;
B,f are two inputs variables, whereas B0 and f0 are known constants. K(1),K(2) are the coefficients to be determined. In short, JordanMdl=f(B,f). I tried to use the built-in function lsqcurvefit, but one variable must be deactivated to let it run(e.g. f, and thus JordanMdl=f(B)), and the coefficients that were figured out differed greatly for different values of this deactivated variable. Apparently, curve fitting can only take one input while matching the random data points, and does not serve my purpose well. I wonder if there is any handy built-in functions/algorithum that can fulfill this purpose. Thanks a lot!
0 个评论
回答(1 个)
Star Strider
2018-5-13
The easiest way to approach this is to create a separate matrix from ‘B’ and ‘f’, then pass that as your independent variable:
JordanMdlShell = @(K,Bf) JordanMdl(K,Bf(:,1),Bf(:,2));
where:
Bf = [B(:) f(:)];
This creates ‘Bf’ as an (Nx2) matrix. This also requires that your dependent variable becomes a column vector, for example: ‘Y(:)’. Change that if you want them as row vectors.
This should work with lsqcurvefit.
2 个评论
Star Strider
2018-5-14
You cannot use ‘Loss_1000Hz’ and ‘Loss_2500Hz’ in your model because they do not have the same lengths as your other data.
Alternatively, you can use all the columns, although using only rows 3 through 12 (so that B<=1).
Those are the only options that I see.
Good luck!
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Mathematics and Optimization 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!