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!