FIRST, NEVER return a variable that has the same name as your function. That is a dangerously, recursively incestuous operation surely going to cause a problem.
function result = diferencia(sigma)
f_m = linspace(120,2500,1e5);
Zc = Z0*(1 + 0.057*X.^(-0.754) - 1j*0.087*X.^(-0.732));
k = k0.*(1 + 0.0978*X.^(-0.7) - 1j*0.189*X.^(-0.595));
R = (Zs - Z0)./(Zs + Z0);
Next, what error did you get when you called fminbnd? IF YOU GET AN ERROR, TELL US WHAT THE ERROR WAS! Paste in the ENTIRE error response. everything in red.
Anyway, if I call your code, does it return a scalar when a scalar input is pased in ? NO! What is the requirement of codes lke fminbnd? READ THE HELP!
Is that a scalar value? It looks vaguely like a vector. Can fminbnd optimize a function that returns an entire vector? NO.
Your problem is not that you cannot optimize a function that takes only scalar input. It is that you apparently do not understand the purpose of an optimizer. An optimizer like fminbnd is designed to take a function that takes an input, and produces a SCALAR output. It finds the value of the input that minimizes the result.
I do note that in your test example, test DOES return a scalar value. But for some reason, you did not decide to do the same with the function diferencia. I don't even know what it means to minimize a vector.
So what is it about that vector of length 1e5 that you return that you wish to optimize?