MATLAB: Function index is a string, why

function

function [ Xs ] = RegulaRaiz( Fun,a,b,ErrMax )
imax=100;
Fa= Fun(a)
Fb=Fun(b)
The code for fun is:
function y = Fun(x)
y = (sin(x)/(3*x))-0.25;
end
If I call the function as RegulaRaiz( 'Fun',1,2,0.0001 )
Fa becomes f and fb becomes u, how do i fix this?

Best Answer

The first input 'Fun' to the function RegulaRaiz is 1x3 char, 'Fun'. So Fa = Fun(1) is f and, Fb = Fun(2) = u.
Could you try
RegulaRaiz(@(x) Fun(x),1,2,0.0001)
instead? Specify the function as an input using a function handle @(x) Fun(x).