Fitting 4 data sets to non-linear least squares

1 view (last 30 days)
jgd0008
jgd0008 on 1 Dec 2016
Edited: jgd0008 on 2 Dec 2016
Hello there,
Im trying to fit 4 data sets to an analytical model. Im looking for K1, where K1(u,v,r,theta). It gives me a "Exiting due to infeasibility: 1 lower bound exceeds the corresponding upper bound" error I´m pretty sure is because the 4 parameters as lsqcurvefit seems it works only with 2 sets of data, and I have 4. For data, you can use the attached txt file. Thanks in advance JGD0008
This is my code: *************
clear all; close all; clc; format long
E=200000; % MPa
nu=0.3; % poisson
global G k u v;
G=E/(2*(1+nu)); % shear mod
k=(3-nu)/(1+nu); %kolosov
A = xlsread('img55_DCT.xlsx'); %excel file with experimental data
x=A(:,1); y=A(:,2);
u=A(:,3);
v=A(:,4);
[m,n]=size(A);
r=zeros(m,1);
theta=zeros(m,1);
for i = 1:1:m %angle rotation according to Irving´s Ref System (X to left, Y down)
r(i,1)=sqrt(x(i,1)^2+y(i,1)^2);
if x(i,1) >= 0 && y(i,1)>=0 % I Q
theta(i,1)=acos(x(i,1)/r(i,1)); %IQ
end
if x(i,1) < 0 && y(i,1)>=0 % II Q
theta(i,1)=acos(x(i,1)/r(i,1)); %II Q
end
if x(i,1) < 0 && y(i,1)<0 % III Q
theta(i,1)=-acos(x(i,1)/r(i,1)); %-I Q
end
if x(i,1) > 0 && y(i,1)<0 % IV Q
theta(i,1)=-acos(x(i,1)/r(i,1)); %-II Q
end
end
% x0 = [1 25]; % initial guess K1 & K2
x0 = 30; % initial guess K1
% [K1, K2] = lsqcurvefit(@series,x0,r,theta); % two parameters
[K1, resnorm]= lsqcurvefit(@series,x0,r,theta, u, v);
****************
%function
function fseries = series(K1,r,theta)
global G k u v;
fseries=2*G*sqrt(2*pi./r)*(u./(sin(theta/2)*(k+1+2*(cos(theta/2))^2))-v./(cos(theta/2)*(k-1-2*(sin(theta/2))^2)))-K1(1);
***************
  2 Comments
Alan Weiss
Alan Weiss on 1 Dec 2016
Please edit your code using the {} Code button so that we can read it.
Alan Weiss
MATLAB mathematical toolbox documentation

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!