Passing functions as arguements in Matlab
Posted
by Dave
on Stack Overflow
See other posts from Stack Overflow
or by Dave
Published on 2010-04-28T13:52:47Z
Indexed on
2010/04/28
14:03 UTC
Read the original article
Hit count: 260
Hi,
I'm trying to write a function that is gets two arrays and the name of another function as arguements.
e.g.
main.m:
x=[0 0.2 0.4 0.6 0.8 1.0];
y=[0 0.2 0.4 0.6 0.8 1.0];
func2(x,y,'func2eq')
func 2.m :
function t =func2(x, y, z, 'func') //"unexpected matlab expression" error message here
t= func(x,y,z);
func2eq.m:
function z= func2eq(x,y)
z= x + sin(pi * x)* exp(y);
Matlab tells gives me the above error message. I've never passed a function name as an arguement before. Where am I going wrong?
p.s. sorry about the formatting of code above, I can't seems to get SO to show parts of the code as code.
© Stack Overflow or respective owner