필터 지우기
필터 지우기

Surface fit to determine the coefficients of a hypothetical equation

조회 수: 2 (최근 30일)
Bohan Liu
Bohan Liu 2018년 5월 13일
댓글: Star Strider 2018년 5월 14일
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!

답변 (1개)

Star Strider
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
Bohan Liu
Bohan Liu 2018년 5월 14일
Hi, thanks for your proposed solution. But the thing is it triggered an error message, saying index exceeds matrix dimensions. One tricky thing about this solution is that, it was assumed that B and f had the same length but actually they did not. I tried to modify B to be the same size as f yet it did not work. Please find attached a snapshot of the error message and the data points with which I want to perform the curve fit. Then you will get a better picture of my task. Thanks again!
Star Strider
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 CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by