# How can I calculate unknown parameters in a integration with given boundary conditions

1 view (last 30 days)
john zhang on 11 May 2020
Commented: john zhang on 13 May 2020
Hi I am trying to calculate unknown parameters in a integration with given boundary conditions. The integration and boundary conditions are shown below:
a11-a23 are the six unknown parameters to be calculated. z1 is a known vector when t=1 (I can give z2, z3... if needed).
The x could be discretized and thus the z1 can be a known vector constant.
I am trying to use integration (int in matlab) to represent z(x,t) for a given x (e.g. x=-1.5:0.1:1.5) and then use fmincon to find a11-a23 to make modulus of (Z(x,t)-z1) the minimum. However, the calculation of the integration is super time-consuming.
c=0.011;
syms x t a1 a2 a3 a4 a5 a6
a=[a1 a2 a3 a4 a5 a6];
x=-1.5:0.1:1.5;
Er=@(t)-(a(1)+a(2)*exp(-t./a(3))).*(1-x.^2./(a(4)+a(5).*t-a(6).*t.^2).^2).^c;
intE=int(@(t)Er(t),t,0,1);
tt=1;% integration time
FEr=Er(x,t,a)
fun=@(t,a)(norm(int(Er,t,0,tt)-z1));
a0=zeros(6,1);
A=[];
b=[];
Aeq=[];
beq=[];
lb=[0,0,0,0,0,0];
ub=[1,1,10,1,1,1];
aa=fmincon(@(a)fun,a0,A,b,Aeq,beq,lb,ub);
Any ideas appreciated. Thank you in advance!
##### 2 CommentsShowHide 1 older comment
john zhang on 11 May 2020
Hi Walter, many thanks for your prompt comments. In my problem, x can be discretized so that z1 can be a vector constant, i.e. for each discreted x along -1.5 to 1.5, I will have a know z for this x when t=1.

Walter Roberson on 11 May 2020
Probably the easiest way is to use the CurveFitting Toolbox with 'fittype' being an anonymous function with 6 model parameters. See https://www.mathworks.com/help/curvefit/fittype.html#btpaend-8
john zhang on 13 May 2020
Hi Walter, thanks for your answer. You remind me that I can use fitting functions (nlinfit or lsqcurvefit) to calculate the 6 model parameters.
Here are some links which may be of help to solve this problem:

### Community Treasure Hunt

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

Start Hunting!