An implementation issue with MatlabFunction
显示 更早的评论
Hello,
I have a question which I explain by an example.
function ll = LL(X1,X2,X01,X02,par1,par2,par3,par4,par5,par6)
THE BODY WILL BE EXPLAINED LATER
end
PLEASE NOTE THAT MY ACTUAL PROBLEM IS MORE COMPLICATED THAN THIS. SO, PLEASE GIVE ME GENERAL ADVICES RATHER THAN A SPECIFIC ONES WHICH PROBABLY WORK FOR THIS PROBLEM ONLY. THANKS!
This function is created by the followig commands
syms x y
syms X X0 [1 2]
syms par [1 6]
mu1(x,y)=[par(1)*x^2*y+par(2)*y^3+x^3;par(3)*x^5*y^7+par(4)*y];sigma1(x,y)=[par(5)+x*y -x;y^2*x x*y*par(6)];
V=argnames(mu1);
p=sym2cell(X0);
mu_X0=subs(mu1,V,X0).';mu_X0=mu_X0(p{:});
sigma_X0=subs(sigma1,V,X0);sigma_X0=sigma_X0(p{:});
D=sigma_X0*sigma_X0.'; det_D=simplify(det(D)); inv_D=simplify(inv(D));
dt=1;S=1/dt*(X-X0-mu_X0*dt)*inv_D*(X-X0-mu_X0*dt).';
d=2;LL=-1/2*(d*log(2*pi*dt)+log(det_D)+S);
LL=matlabFunction(LL,'File','LL','vars',[X X0 par],'Outputs',{'ll'}); %Log-Likelihood
My question: I wouldlike to make a slight change to the way this matlabfunction is created so that at the end it would look like the following
function ll = LL(X,X0,par1,par2,par3,par4,par5,par6)
BODY: here, instead of stuff like X1,X2,X01,X02 I would like to have stuff like X(1),X(2),X0(1),X0(2)
end
I find it difficult to implement this (and this is very annoying).
I look forward to your kind help!
Thanks,
Babak
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Mathematics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
