As Donnie mentioned in their comment, the variable e
is undefined in your m-file.
If you have defined e
elsewhere, you have to pass it to myfun
so that the function knows its value. Since fplot
does not accept plotting functions with more than one input value, you need to pass it an anonymous function.
First, you need to change the definition of myfun
to include e
as input:
function Y = myfun(x,e)
Y(:,1) = 3*x;
Y(:,2) = e(:).^x;
Then, you create your function handle fh like this (fh still only takes one input, Matlab uses the value of e
as it was defined in the workspace at the time you create the function handle):
fh = @(x)(myfun(x,e))
Finally, you can call fplot like you used to
fplot(fh,[-2 4])