Y=sqrt((A^​2*X^2+B^2*​X^2)/(C+D^​2*X^2))

3 views (last 30 days)
Y=sqrt((A^2*X^2+B^2*X^2)/(C+D^2*X^2))
Hello, In above equation X and Y are obtained from measurement, can we find A B and C which are parameters using measurement data in MATLAB
  1 Comment
Rik
Rik on 16 May 2019
There will not be a unique solution, because this can be simplified to the code below. Otherwise I see no reason why you could fit parameters to this function.
Y=sqrt(((A^2+B^2)*X^2)/(C+D^2*X^2));
%or:
Y=sqrt( (p(1).*X.^2)./(p(2)+p(3).*X.^2) );

Sign in to comment.

Accepted Answer

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 16 May 2019
Edited: Sulaymon Eshkabilov on 16 May 2019
Hi,
Here are three solutions with lsqcurverfit and non-linear lsqfit.
% Use of LSQCURVEFIT from the optimization toolbox
x = (0:.1:2)'; % You need to plug in your data
y =[ 0.0027518, 0.028328, 0.080677, 0.13821, 0.14972, 0.24813, 0.32113 ...
0.36436, 0.35548, 0.4302, .50379, 0.54335, 0.58321, 0.67395, .67685 ...
0.57845, 0.70758, 0.87197 0.80164 0.84333 0.76828]; % You need to plug in your data
abcd0=[1 1 1];
RP=@(abcd,x)sqrt(abcd(1)*x.^2./(abcd(2)+abcd(3)*x.^2));
[abcd, error]=lsqcurvefit(RP, abcd0, x, y');
yfit=sqrt(abcd(1)*x.^2./(abcd(2)+abcd(3)*x.^2));
plot(x,y, 'o', x, yfit, '-');
J=sum((yfit-Y').^2); S=sum((Y-mean(Y)).^2); R_sq=1-J/S;
abcd %# ok To see the coeff values of A (A & B combined), B (A & B combined), C, D
%% Alternative: NON-Linear-least-squares fit model
clearvars
x = (0:.1:2)';
y =[ 0.0027518, 0.028328, 0.080677, 0.13821, 0.14972, 0.24813, 0.32113 ...
0.36436, 0.35548, 0.4302, .50379, 0.54335, 0.58321, 0.67395, .67685 ...
0.57845, 0.70758, 0.87197 0.80164 0.84333 0.76828]';
ft = fittype( 'sqrt((abc1*x^2+abc2*x^2)/(abc3+abc4*x^2))', 'coeff', {'abc1', 'abc2', 'abc3', 'abc4'} );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';% Fit model to data.
[fitresult, gof] = fit( x, y, ft, opts );
% Plot fit with data.
figure( 'Name', 'CFTOOL fit: exponential fit 1' );
h = plot( fitresult, x, y);
legend( h, 'y1 vs. x1', 'Sine & Cosine fit 1', 'Location', 'NorthEast' );
% Label axes
xlabel x1; ylabel y1; grid on; shg
fitresult %#ok shows all values of abc1, abc2, abc3, abc4, viz. A, B, C, D
%% An alternative LSQCURVEFIT
x = (0:.1:2)';
y =[ 0.0027518, 0.028328, 0.080677, 0.13821, 0.14972, 0.24813, 0.32113 ...
0.36436, 0.35548, 0.4302, .50379, 0.54335, 0.58321, 0.67395, .67685 ...
0.57845, 0.70758, 0.87197 0.80164 0.84333 0.76828];
abcd0=[1 1 1 1];
RP=@(abcd,x)sqrt((abcd(1)*x.^2+abcd(2)*x.^2)./(abcd(3)+abcd(4)*x.^2));
[abcd, error]=lsqcurvefit(RP, abcd0, x, y');
yfit=sqrt((abcd(1)*x.^2+abcd(2)*x.^2)./(abcd(3)+abcd(4)*x.^2));
plot(x,y, 'o', x, yfit, '-');
J=sum((yfit-y').^2); S=sum((y-mean(y)).^2); R_sq=1-J/S;
abcd %#ok to see the coeff. values: A, B, C, D
Good luck.

More Answers (1)

John D'Errico
John D'Errico on 17 May 2019
Edited: John D'Errico on 17 May 2019
People still seem to be missing that the fit will NOT be unique. The model cannot be estimated uniquely as it has been posed. First, start with the original model posed:
y = sqrt((A^2*X^2+B^2*X^2)/(C+D^2*X^2))
Here, both Rik and Sulaymon have seen that the term
A^2*X^2+B^2*X^2
can be reduced without significant loss of generality into the general form
p(1)*X^2
That is, given a solution for p(1) (as long as p(1) is positive!), you can choose any value for A that does not exceed sqrt(p(1)). Then there will be infinitely many values for B that you can choose.
So we can reduce the original model posed to this:
y = sqrt((p(1)*X^2)/(p(2)+p(3)*X^2))
But be careful STILL! I would point out that Nithin has asked to fit parcmeters only for A,B,C, thus leaving D fixed by the user. That was intelligent! It seems to recognize that you cannot extimate all parameters in such a ratio uniquely. That is, in thius reduced model:
y = sqrt((p(1)*X^2)/(p(2)+p(3)*X^2))
if you finally find any result for [p(1), p(2), p(3)], then an eq\uially valid related set of parameters exists of the form
[p(1)*k, p(2)*k, p(3)*k]
This holds true for ANY value of k. It leads me to claim that the model you can estimate is a TWO parameter model:
y = sqrt((p(1)*X^2)/(p(2)+D^2*X^2))
I've replaced p(3) with D^2, as originally posed. So if D is chosen initially by the user, and FIXED in value, now you can uniquely estimate the other two parameters. Whether the model will fit or not, that is relevant only to the data provided.
There will in fact be constraints on the problem, in that if p(1) is negative, then you will get an imaginary result from the sqrt. So we need p(1) to be positive.
Next, you should see that for positive p(1), then P(2) actually has a lower bound of -D^2*min(abs(X))^2.
So, now, since we can pick any arbitrary value for D, I'll pick D == 1. That allows me to reduce the model to a simplest, unambiguous form:
y = sqrt((p(1)*X^2)/(p(2) + X^2))
the lower bounds for p will be 0 for p(1), and -min(abs(X))^2 for p(2). Both of p(1) and p(2) have no upper bound.
Since p(1) is something we will estimate anyway, I could as easily have written it as:
y = p(1)*X./sqrt(p(2) + X^2))
  1 Comment
Sulaymon Eshkabilov
Sulaymon Eshkabilov on 17 May 2019
In my proposed solution, I am propose two case scenarious:
1) sqrt((p(1)*X^2)/(p(2)+p(3)*X^2))
2) sqrt((A^2*X^2+B^2*X^2)/(C+D^2*X^2))

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!