Encountering error with using lsqcurvefit
Afficher commentaires plus anciens
I have the following experimental data.
xdata = [1 1.01 1.12 1.24 1.39 1.61 1.89 2.17 2.42 3.01 3.58 4.03 4.76 5.36 5.76 6.16 6.40 6.62 6.87 7.05 7.16 7.27 7.43 7.50 7.61];
ydata = [0 0.03 0.14 0.23 0.32 0.41 0.50 0.58 0.67 0.85 1.04 1.21 1.58 1.94 2.29 2.67 3.02 3.39 3.75 4.12 4.47 4.85 5.21 5.57 6.30];
I am trying to fit the ydata, which are stresses denoted by P, to the analytical equivalent (see equation) where the xdata represents the corresponding strains denoted by λ.

I am attempting to use the lsqcurvefit function in the follwing script but I am encountering an error. How may I resolve this? I am unfamiliar with most of the information returned to me
clear all
close all
clc
% xdata (Stretch, Lamda)
xdata = [1 1.01 1.12 1.24 1.39 1.61 1.89 2.17 2.42 3.01 3.58 4.03 4.76 5.36 5.76 6.16 6.40 6.62 6.87 7.05 7.16 7.27 7.43 7.50 7.61];
% ydata (Nominal Stress, P)
ydata = [0 0.03 0.14 0.23 0.32 0.41 0.50 0.58 0.67 0.85 1.04 1.21 1.58 1.94 2.29 2.67 3.02 3.39 3.75 4.12 4.47 4.85 5.21 5.57 6.30];
% Proposition
% ydata = (a*b*xdata^3 - 1))/(xdata)*(xdata*b - xdata^3 + 3*xdata - 2));
% Gent Model Y-Axis
gent_function = @(x,xdata)(x(1)*x(2)*(xdata^3 - 1))/((xdata)*(xdata*x(2) - xdata^3 + 3*xdata - 2));
% Fit Model w/ Start
x0 = [100, 0.1];
x = lsqcurvefit(gent_function,x0,xdata,ydata);
% Plot Data & Fitted Curve
times = linspace(xdata(1),xdata(end));
plot(xdata,ydata,'ko',times,gent_function(x,times),'b-')
legend('Data','Fitted Exponential')
title('Data and Fitted Curve')
--------------------------------------------------------------------------------------------------
Error using ^ (line 51)
Incorrect dimensions for raising a matrix to a
power. Check that the matrix is square and the power
is a scalar. To perform elementwise matrix powers,
use '.^'.
Error in
check>@(x,xdata)(x(1)*x(2)*(xdata^3-1))/((xdata)*(xdata*x(2)-xdata^3+3*xdata-2))
(line 15)
gent_function = @(x,xdata)(x(1)*x(2)*(xdata^3 -
1))/((xdata)*(xdata*x(2) - xdata^3 + 3*xdata - 2));
Error in lsqcurvefit (line 225)
initVals.F =
feval(funfcn_x_xdata{3},xCurrent,XDATA,varargin{:});
Error in check (line 19)
x = lsqcurvefit(gent_function,x0,xdata,ydata);
Caused by:
Failure in initial objective function
evaluation. LSQCURVEFIT cannot continue.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Nonlinear Optimization dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


