I have a symbolic integral with symbolic parameters (x(1), x(2),x(3),t). I am trying to fit this symbolic integral to experimental data and acquire those parameteres (x(1),x(2),x(3)). I tried to use fminsearch or fmincon; however, I couldn't use them and I faced different errors. for example: is not a valid MATLAB expression, has non-scalar coefficients, or cannot be evaluated: Error while trying to evaluate FITTYPE function. I attach my code. would you please help me to solve this error.

Thanks

clear all;

clc;

%%

beta=0.002;

alfa=0.004;

nu=0.49;

del=0.010;

t0=1.35;

syms eta G1 G2 A s t taw

x=sym('x',[1 3]);

p1=(eta)/(G1+G2);

q1=(2*G1*eta)/(G1+G2);

q0=(2*G1*G2)/(G1+G2);

B1=(2*G1*(1+nu))/(3*(1-2*nu));

B2=(2*G2*(1+nu))/(3*(1-2*nu));

B3=(2*eta*(1+nu))/(3*(1-2*nu));

q2=3*B1*B2/(B1+B2);

q3=B3/(B1+B2);

q4=3*B1*B3/(B1+B2);

Pc1=1+p1*A;

Qc1=q0+q1*A;

Pc2=1;

Qc2=q2;

f1=Pc1*Qc2*Pc1+2*Pc1*Pc2*Qc1;

c1 = coeffs(f1, A);

c1=simplify(c1);

f2=2*Pc1*Qc1*Qc2+Qc1*Pc2*Qc1;

c2=coeffs(f2,A);

c2=simplify(c2);

GG2=ilaplace((4*beta/(3*t0*sqrt(alfa)))*del*(c2(1,3)*s^2+c2(1,2)*s+c2(1,1))/((c1(1,3)*s^3+c1(1,2)*s^2+c1(1,1)*s)), t);

GGs2=subs(GG2, t, t-taw);

GGss2=subs(GGs2, {G1,G2,eta}, {x(1),x(2),x(3)});

assume(x(1) > 0)

assume(x(2) > 0)

assume(x(3) > 0)

assume(x(1),'real')

assume(x(2),'real')

assume(x(3),'real')

force2=int(GGss2*diff(taw^1.5,taw),taw,0,t0,'IgnoreAnalyticConstraints',true);

t0=[2 12 22 32 42 52 62 72 82 92 102 112];

F0=[0.77618 0.7259 0.70212 0.7011 0.69315 0.69324 0.67682 0.67658 0.67618 0.67669 0.67623 0.66831];

B2 = simplify(force2);

F2 = matlabFunction(B2,'vars', [{x(1),x(2),x(3)},t]);

%---------------------------------Error------------------------------------

funcfit1=fittype(F2,'indep','t','coefficients', {'x1','x2','x3'});

%--------------------------------------------------------------------------

F22=subs(numinteg, t, t0);

% fminsearch algorithm

fun = sum((F0-F22).^2);

%starting guess

pguess = [1000,1000,1000];

%optimise

[p,fminres] = fminsearch(fun,pguess)

More Seyed Jamaleddin Mostafavi Yazdi's questions See All
Similar questions and discussions