Curve fitting to an excel file

3 vues (au cours des 30 derniers jours)
James Blackwell
James Blackwell le 15 Nov 2018
Commenté : James Blackwell le 16 Nov 2018
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!

Réponse acceptée

madhan ravi
madhan ravi le 15 Nov 2018
Modifié(e) : madhan ravi le 15 Nov 2018
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')
  1 commentaire
James Blackwell
James Blackwell le 16 Nov 2018
Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with Curve Fitting Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by