coefficient determination of two variables

조회 수: 7 (최근 30일)
Duy Hai Nguyen
Duy Hai Nguyen 2020년 6월 29일
편집: Matt J 2020년 7월 4일
Hello everyone,
I would like to ask you some guidelines about how to solve this equation in matlab. This is an equation for an admittance of the open ended coaxial probe.
I would like to find the coefficients $\alpha$ and $\beta$ in the equation based on my measured data, in which those parameters are known: $\epsilon_r$, s, a and Y. The upper bound (N,M,P,Q) we can choose. For example, N=M = 4; P=Q=8.
I think some kind of fitting function might address my question, but I am really new to Matlab and have no ideas to do that.
Thank you very much,
Greetings

채택된 답변

Matt J
Matt J 2020년 6월 29일
lsqcurvefit would be one choice,
Note that your equation can be reorganized as a linear equation by multiplying through by the denominator expression involving the betas. That would likely be a good way fo developing an initial guess for the parameters.
  댓글 수: 9
Duy Hai Nguyen
Duy Hai Nguyen 2020년 7월 4일
Dear Matt,
sorry to bother you again. When I try your code alone, there is no error. However, when I put the lsqcurvefit to find the alpha, beta. I got error of the size of the matrix. Please see below:
Here is the code for the alphabeta, I guess there should not any changes:
AlphaBeta = lsqcurvefit(y_model,[alpha_0,beta_0],[],y_ref);
And here is the error:
Error using reshape
Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that
dimension.
Error in openEndedCoax>modelfunc (line 61)
Alpha=reshape(alphabeta(:,1),N,P); %unpack into matrix form
Error in openEndedCoax>@(alphabeta,~)modelfunc(alphabeta,freq,eps_ref,a,N,P,M,Q) (line 49)
y_model = @(alphabeta,~) modelfunc(alphabeta,freq,eps_ref,a,N,P,M,Q);
Error in lsqcurvefit (line 222)
initVals.F = feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:});
Error in openEndedCoax (line 58)
AlphaBeta = lsqcurvefit(y_model,[alpha_0,beta_0],[],y_ref);
Caused by:
Failure in initial objective function evaluation. LSQCURVEFIT cannot continue.
Do you have any ideas?
Greetings,
Matt J
Matt J 2020년 7월 4일
편집: Matt J 2020년 7월 4일
Yes, the N and P you've passed in do not agree with the size of alphabeta. You should get in the habit of using dbstop
to probe such errors.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Programming and Mixed-Integer Linear Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by