Efficient implementation of a functions with vector arguments
Mostrar comentarios más antiguos
I am an inexperienced MATLAB user. I need to define functions with an efficient implementation because they will be called many times. The function arguments are 3-D vectors, and the functions need access to individual elements of the vectors. The following is a toy example.
function y = foo( vector )
y = vector(1)*cos(vector(2))/(1+vector(3));
end
--------------------------
Then I could do
v = [2,pi/3,2];
foo(v)
ans = 0.3333
Is there a more efficient way to implement the above function?
Thanks, Ted Ersek
1 comentario
Sean de Wolski
el 3 de Abr. de 2013
What does your real vector look like and what would you expect for the output?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Optimization 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!