Definite integral in (embedded) Matlab function, with passing additional parameters to the integrand
显示 更早的评论
Hi,
I have a simulation file to model the dynamic behaviour of system, at each time step , I need to evaluate a time-independent integral. To do so I use (embedded) Matlab function but I got many errors. Any help would be appreciated.
inside my (embedded) Matlab function is:
%%________________ method one
function forces=my_embeded_func(positions)
y1=position(1);
y2=position(2);
forces=integral(@(theta),y1+y2*theta,0,2*pi)
end
%_______________
Notes: 1-my integrand is actually very complicated but I put something simple here.
2-I have been told to use "quadgk" instead of "inregra;", but it did not worked
3- I also tried the following method but it did not helped!
%%________________ method two
function forces=my_embeded_func(positions)
coder.extrinsic('myFunc')
y1=position(1);
y2=position(2);
forces=myFunc(y1,y2)
end
% where
function a=myFunc(y1,y2)
a=quadgk(@(theta),y1+y2*theta,0,2*pi)
end
%_______________
Thanks,
Ehsan
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!