MATLAB: Y=sqrt((A^2*X^2+B^2*X^2)/(C+D^2*X^2)) MATLAB 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 Best Answer Hi,Here are three solutions with lsqcurverfit and non-linear lsqfit.% Use of LSQCURVEFIT from the optimization toolboxx = (0:.1:2)'; % You need to plug in your datay =[ 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 dataabcd0=[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 clearvarsx = (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 axesxlabel x1; ylabel y1; grid on; shgfitresult %#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, DGood luck. Related SolutionsMATLAB: Calculate slope from linear fit data The intercept is indeed 0.5. Intercept is the value on y-axis when x=0. Whereas you 2.2 is the value when x=1. MATLAB: Fitting data to a limaçon curve Here's a poor man's method, assuming you don't have the Optimization or Curve Fit Toolboxes z=x.^2+y.^2; %Cheesy initial guess of p=[a,sqrt(b)] p= [x, sqrt(z)]\z; p(2)=max(p(2),0); %b must be positive %Re-optimize p0=p; p=fminsearch(@(p) norm( (z-p(1).*x).^2 - z.*p(2).^2 ), p0 ); a=p(1); b=p(2)^2; Related QuestionSolving system of integral equations – Error FSOLVE cannot continueHi!!! i am using Matlab for the first time!) Please, Can u Help me to solve a non-linear system?!Polynominal Fitting Constrained in 1 CoefficientDoes code choke at line 22; mesh(xFIT,yFIT,YFIT). Att: x var in Col 1, y var in Col 2 and z var in col 3. Code &error below. We get the scatter; not the mesh. (Save xl file to C:\, upload: Home>Import Data>Import>Import Selection, run code)
Best Answer