MATLAB Answers

coefficient determination of two variables

6 views (last 30 days)
Duy Hai Nguyen
Duy Hai Nguyen on 29 Jun 2020
Edited: Matt J on 4 Jul 2020
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

  0 Comments

Sign in to comment.

Accepted Answer

Matt J
Matt J on 29 Jun 2020
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 Comments

Show 6 older comments
Duy Hai Nguyen
Duy Hai Nguyen on 4 Jul 2020
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 on 4 Jul 2020
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.

Sign in to comment.

More Answers (0)