# Question:Use of procedure in DataFit

## Question:Use of procedure in DataFit

Maple

Hello,

I'm trying to fit experimental data to a model in which a variable is the result of an equation.

In a procedure I solved the equation and found lambda22 for each of the data lambda11 I have. It depends on a a parameter I need to identify to fit the data to the model.

But then when I use DataFit from DirectSearch package, I get this error :

## Error, (in DirectSearch:-DataFit) Vector (Matrix) with values of independent or dependent variables is missing

Is it impossible to specify more than one independant variable ? Or is it a problem coming from the procedure ?

Manon

data.xlsx

```restart;

data:=ExcelTools:-Import("D:/data.xlsx") : # importer les donnees
with(LinearAlgebra):
lambdaX:=Column(data,1):
PK1X:=Column(data,2):

tensF:=Matrix([[lambda11,0,0],[0,lambda22,0],[0,0,lambda22]]):
tensFbar:=Matrix([[(lambda11/lambda22)^(2/3),0,0],[0,1/sqrt((lambda11/lambda22)^(2/3)),0],[0,0,1/sqrt((lambda11/lambda22)^(2/3))]]):
tensBbar:=Multiply(tensFbar,Transpose(tensFbar)):

kappa:=100:
tensPK:=Multiply(Transpose(MatrixInverse(tensF)),(2/Determinant(tensF))*a*(tensBbar-(1/3)*Trace(tensBbar)*Matrix(3,shape=identity))+kappa*(Determinant(tensF)-1)*Matrix(3,shape=identity)):
PK1:=tensPK[1,1]:
eq:=0=tensPK[2,2]:

lambda22sol:=proc(aValue)
global __old_a;
local res, i, eq1, sol1, lambda22Est;
if not [aValue]::list(numeric) then
return 'procname'(args);
end if;
lambda22Est:=Vector(1..RowDimension(lambdaX)):
eq1:=Array(1..RowDimension(lambdaX)):
if __old_a<>aValue then
__old_a:= aValue;
for i from 1 to RowDimension(lambdaX) do
eq1[i]:=eval(eq,[a=aValue,lambda11=lambdaX[i]]):
sol1:=solve(eq1[i], lambda22);
lambda22Est[i]:=sol1[1]:
end do:
res:=lambda22Est;
end if;
end proc:

matrix1:=<lambdaX|lambda22sol(0.9)|PK1X>;
DS1:=CodeTools:-Usage(
DirectSearch:-DataFit(PK1,matrix1,[lambda11,lambda22]));
res2:=eval(PK1,DS1[2]):```

﻿