I'm trying to solve a transcendental equation for the variable 'neff'. I have a function in a file called 'transcendental' containing this function, which I then call in the main code and pass into fsolve. I need to be able to pass in the value of 'w', however. The code works when 'w' is inside the function, but I can't find a way to be able to pass 'w' into the function.
I'm new to matlab and have really tried to fix this for hours with anonymous functions, nested functions, you name it. I would be extremely grateful for any help!
function saved in 'transcendental.m':
function[fun] = F(neff,w)w = 1.26*10e15c = 2.998e8ns = 1.5nc = 1.0d = 2e-6beta = (w/c)*neffk = sqrt(((w^2)/(c^2))*(ns)^2 - beta^2)g = sqrt(beta^2 - (nc)^2*((w^2)/(c^2)))fun = tan(k*d)+k/g
main code:
fun = @transcendentalx0 = [1.2]answer = fsolve(@transcendental, x0)
Best Answer