Curve fitting to an excel file

4 次查看(过去 30 天)
Hi,
I am trying to fit an analytic formula to an experiment I carried out. It's a simple compression test of a material.
The code to generate a plot is:
a = 133; % area of surface mm^2
Area = pi*a^2;
%Want to plot Sigma v L
W1 = 0.01;
W2 = 0.01;
L = linspace(1,0.8,225);
sigma = (2.*W1.*((L.^2) - 1./L) - 2.*W2.*((1./L.^2) - L));
F = -(Area .* sigma);
deformation = (1-L)*100
plot(deformation,F)
xlabel('% strain'), ylabel('Force mN')
W1 & W2 are just placeholder values, those are the values I am trying to find. They give a value of roughly 1600mN at 20% which is close to the actual value of 1815, but the shape is off. It is linear rather than a gentle curve
I would like to do a non-linear least squares fit to the data I have.
I can input the excel file and it all shows up fine. I have data of both strain and Force.
filename = 'C_P_1.xlsx';
Test = xlsread(filename);
But I don't know how to implement the fitting. Starting values for the strain would be 0%, finishing at 20%. Starting values for the force are 0 and finish at 1815 mN at 20% strain.
Any help would be greatly appreciated!

采纳的回答

madhan ravi
madhan ravi 2018-11-15
编辑:madhan ravi 2018-11-15
use interp1() with suitable method:
a = 133; % area of surface mm^2
Area = pi*a^2;
%Want to plot Sigma v L
W1 = 0.01;
W2 = 0.01;
L = linspace(1,0.8,225);
sigma = (2.*W1.*((L.^2) - 1./L) - 2.*W2.*((1./L.^2) - L));
F = -(Area .* sigma);
deformation = (1-L)*100;
xx=linspace(deformation(1),deformation(end),1000);
yy=interp1(deformation,F,xx,'spline');
plot(deformation,F,'o',xx,yy,'r')
xlabel('% strain'), ylabel('Force mN')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by