Curve fitting to an excel file

4 ビュー (過去 30 日間)
James Blackwell
James Blackwell 2018 年 11 月 15 日
コメント済み: James Blackwell 2018 年 11 月 16 日
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')
  1 件のコメント
James Blackwell
James Blackwell 2018 年 11 月 16 日
Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet 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