Definite integral in (embedded) Matlab function, with passing additional parameters to the integrand
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!