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!
댓글 수: 0
채택된 답변
madhan ravi
2018년 11월 15일
편집: madhan ravi
2018년 11월 15일
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 Center 및 File 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!