File Exchange

image thumbnail

Optical Fibre Toolbox

version 1.20 (518 KB) by

Simulation of optical fiber modes



View License

Optical Fibre Toolbox (OFT) provides functions for fast automatic calculation of guided modes in simple optical fibres. Developed with tapered microfibres (aka nanofibres) in mind. Exact solutions for weak and strong guidance cases are provided. Material dispersion is taken into account.

Main functionality:
- Find the guided modes.
- Calculate the effective refractive index of each mode for the given diameter and wavelength or versus variable diameter or wavelength (modal dispersion).
- Calculate the electric and magnetic fields of the modes (only two-layer modes).
- Find phase-matching points for harmonic generation in fibres.

A number of additional useful functions is provided.

For installation instruction, see install.txt.
For examples of use, see the demo/ directory.
For the full list of functions, see Contents.m.
For the list of authors, see authors.txt.

==== Version 2.1 (2011-12-08) ====
Bug fix:
- Erdogan modes didn't work for neff vs. wavelength --- fixed.
- Several small stability improvements.

New functionality:
- skipmodes parameter can be specified in mode task. The listed modes will be found by buildModes but not traced
- New materials in refrIndex.

==== Version 2.0 (2011-10-31) ====
This version includes several major changes:
1. First of all, starting with this release OFT supports three-layer structures (double-clad or core-cladding-surrounding). See demo/tutorial3ls.m.
NOTE: The field of three-layer modes cannot yet be calculated.
2. Material refractive index (function refrIndex.m) can now be calculated taking temperature into account.
3. An attempt to start documenting the toolbox is made. Type 'doc contents' to see a full list of functions or 'doc functionname' to see documentation for a specific
4. Also the first tutorial created --- demo/tutorial3ls.m.
5. Starting with this release, the latest stable version of the code will be available at This is mainly done to speed up the process of publishing debug versions and to keep track of the history of releases.

Other changes:
- General code clean up.
- V-parameter calculation added.
- White sector in displayField2.m suppressed in a more correct way.
- Many other small improvements and corrections.

==== 2010-06-12 ====
Several bugs in field display corrected.

==== 2010-06-02 ====
The first public release of OFT (version 1.0). Only two layer structures are supported.

Comments and Ratings (23)


elis02 (view profile)

Hi. A lot of functions :)
I'm looking for a function that takes the sellmier of n_Core, n_Clad and gives me the neff.
Can I use any of these functions?

I apologize that I cannot answer each comment here. The two-layer model implemented in the OFT has been thoroughly checked numerous times. It has been used for a couple of years now to compare against our results in various experiments. Plus it was used to verify the three-layer model, whenever possible. No mistakes have been found in the recent time, the two-layer code is stable. Therefore I am pretty sure there are no mistakes in that part of the code. Mistakes (typos) do occur in books and papers however. Also, different notations and/or assumptions can be made, e.g. concerning the coordinate system or polarisation direction.


Jing (view profile)

I think there might be a mistake.

In the file modeField.m
according to Snyder's book
m is odd, it is HE mode
f=sin(nu*phi); g=cos(nu*phi);

But in your code,
f = @(nu,phi) cos(nu*phi);
g = @(nu,phi) -sin(nu*phi);

Robert, I have just downloaded OFT from this page and run demo/oftDemo.m with Matlab 2009b and 2012b. In both cases it has completed without problems.


Robert (view profile)


Robert (view profile)

I tried out the demo oftDemo without modifications. It found modes and showed me the field profiles, but it also claimed that there are "traceMode WARNING: too little amount of points in the mode" and the dispersion curves that i got were empty.


Robert (view profile)

harsimran, repeating the same question doesn't really help. Unless you provide details on what needs to be calculated, I cannot help you. If you don't know yourself, OFT will not be of help, neither will be Matlab.

O want to implement orthogonal frequency division multiplexing in optical fiber using matlab

harsimran, I am afraid I do not understand your question. What do you mean by "implementing OFDM" with OFT? What exactly do you need to calculate?

Dear sir

Could we implement optical ofdm with optical toolbox.Kindly help me

Mastel, you cannot "launch" the toolbox, it's a set of functions. There are a couple of examples in the demo folder.

Please i just want to know how to launch the OFT through matlab on my computer!


Sean (Xiao)

@choon soon: Sure. Just change the task for the modeField function in oftDemo.m.

Bryan Wong

Kotya:I have one doubt in this toolbox. We can view the field intensity of Hybrid mode. Can we use this toolbox to view the field configuration of TE and TM mode?

@Samuel: All hybrid modes are the solution of the same equation. The first solution is HEm1, second EHm1, third HEm2, fourth EHm2 etc. Therefore to know which exactly hybrid mode you have you just need to know the modal indices. I agree that this is not a very beautiful approach and will implement the direct HE/EH specification in the update.

Samuel Sel

Thanks for the toolbox. One doubt, in the HYBRID mode stated in the program, how are you differentiate whether it is HE or EH mode?

Nicholas, this becomes more a general Matlab discussion than anything related to the toolbox, so if you will have further problems you should probably ask elsewhere. To answer your current question: you are misusing the function handles (in the line "r=@(y)...". Please take a look in the Matlab manual.

Nicholas Tan

@Kotya Karapetyan :
Thank really helps me a lot. However, when i proceed into more complex equations, i can't really get the roots.

JRa= @(y) besselj(1,y);
JR1a= @(y) besselj(0, y) - besselj(1, y)./y;

JRb= @(y) besselj(1,z);
JR1b= @(y) besselj(0, z) - besselj(1, z)./z;

Yb= @(y) bessely(1,z);
Y1b= @(y) bessely(0, z) - bessely(1, z)./z;

Ya= @(y) bessely(1,y);
Y1a= @(y) bessely(0, y) - bessely(1, y)./y;

r=@(y) y.*((JR1a.*Y1b-JR1b.*Y1a)./(JRa.*Y1b-JR1b.*Ya));
u = FindRoot(r, [1 10], 0.5)

Some errors occurred:

??? Undefined function or method 'times' for input arguments of type 'function_handle'.

Error in ==> @(y)y.*((JR1a.*Y1b-JR1b.*Y1a)./(JRa.*Y1b-JR1b.*Ya))

Error in ==> FindRoot at 51
G = g(X);

Could you please help me to identify my mistakes? Thank you in advance.

@Nicholas Tan: You can, but I believe there is an error in your code. The correct code would read:

J1 = @(x) besselj(0, x) - besselj(1, x) ./ x;
J = @(x) besselj(1, x);
f = @(x) x .* (J1(x) ./ J(x));
r = FindRoot(f, [0 10], 0.5)

Nicholas Tan

i saw a function FindRoot in the program. Can i use that function to find the roots of the bessel function?

syms x;
J1=besselj(0, x) - besselj(1, x)./x;
r = FindRoot(f,[0 10],0.5)

From the simulation above, i found an error stated:
??? Error using ==> FindRoot at 86
FINDROOT: Reached max value of ATTEMPT (10) before root was found



A few bugs fixed, minor additional functionality.


Tags updated.


Description, created using, copyright updated.


Test 2011-11-02 14:00 (CET)




Bug in displayField2.m corrected: it was plotting r-, phi- and z-components instead of x-, y- and z-ones.

MATLAB Release
MATLAB 7.13 (R2011b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video