Code covered by the BSD License  

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

» Watch video

Highlights from

4.1 | 52 ratings Rate this file 69 Downloads (last 30 days) File Size: 145 KB File ID: #976 Version: 1.0
image thumbnail




22 Oct 2001 (Updated )

Adaptive Neural Networks

| Watch this File

File Information

The adaptive Neural Network Library (Matlab 5.3.1 and later) is a collection of blocks that implement several Adaptive Neural Networks featuring different adaptation algorithms.

It was developed mainly in June-July 2001 by Giampiero Campa (West Virginia University) and Mario Luca Fravolini (Perugia University). Later improvements were partially supported by the NASA Grant NCC5-685.

There are blocks that implement basically these kinds of neural networks:

Adaptive Linear Networks (ADALINE)

Multilayer Layer Perceptron Networks

Generalized Radial Basis Functions Networks

Dynamic Cell Structure (DCS) Networks with gaussian or conical basis functions

Also, a Simulink example regarding the approximation of a scalar nonlinear function is included.

Finally, the file includes step by step instrucions on how to train the GRBF network and the supporting example.


This file inspired Adaptive Neuro Fuzzy Inference Systems (Anfis) Library For Simulink.

Required Products Simulink
MATLAB release MATLAB 5.3.1 (R11.1)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (71)
02 Jun 2016 Michal Bakinowski

If you have problem something like this - "Error in S-function 'anndemo/GRBF/Mran': S-Function 'emran8' does not exist.", follow these instructions:
1. Rename src.z.p file to
2. Extract the file and open.
3. Copy all files (dcsgl2.c,emran8.c,vrmult.c) to .../extern/examples/mex, eg. /usr/local/MATLAB/MATLAB_Production_Server/R2015a/extern/examples/mex.
4. Replace the "//" before the comments with "/*" and "*/" after the comments in dcsgl2.c file.
5. Open MatLab and type in your command window:
>> copyfile(fullfile(matlabroot,'extern','examples','mex','dcsgl2.c'),'.','f')
>> mex dcsgl2.c
>> copyfile(fullfile(matlabroot,'extern','examples','mex','emran8.c'),'.','f')
>> mex emran8.c
>> copyfile(fullfile(matlabroot,'extern','examples','mex','vrmult.c'),'.','f')
>> mex vrmult.c

If have problem after type 'mex file.c', like:
"Caught "std::exception" Exception message is:
boost::filesystem::status: Permission denied: "/home/user_name/.gvfs""
open terminal "crtl+alt+t" and type:
# sudo umount /home/user_name/.gvfs
# rm -rf ~/.gvfs
and try again 'mex file.c' in the command window.

It works on Linux platform. I don't try it on windows...

26 Feb 2016 Ilias Konsoulas

Wonderful work! Also, I would like to congratulate the author regarding his generocity to share his Level-2 S-function scripts. These are perfect examples for us on how to program efficiently complex, fast, Level-2 S-functions. Thank you very much Dr. Campa!

04 Nov 2015 Bogdan Codres

I've manage to compile mex files for the Matlab 64 bit version. Just use

mex -largeArrayDims vrmult.c
mex -largeArrayDims emran8.c
mex -largeArrayDims dcsgl2.c

For the last file I made some changes in the source file. Replace the "//" before the comments with "/*" and "*/" after the comments.

21 Jan 2013 unal hayta

when i try to open ann.mdl,there is an error. i could not solve it. I tried for both 32 and 64 bit systems. I am using matlab R2009b. please help

Comment only
14 May 2012 Benjamin  
10 Feb 2012 Mohammad Al-Malki  
10 Feb 2012 Mohammad Al-Malki  
13 Dec 2011 Giampiero Campa

For 64bit machines you just have to recompile the code. Just delete the mex32 files, rename src.z.p to, extract the c code, and use mex to generate 64 bits exetutables.

Comment only
20 Oct 2011 Ricky

Ricky (view profile)

Are there any plans to make this library 64-bit compatible? I am trying to update some code to the current version of Matlab/Simulink in a classroom/lab environment where the 64-bit version is installed

Comment only
09 Oct 2011 Mr Smart  
28 Jul 2011 saurabh mishra

Thanks Victor for the help..

I tried as per your suggestions but it's not working...:(

I had seen that linearly separable inputs doesn't need hidden layers.But when I tried , it's not working completely.

Comment only
28 Jul 2011 Victor Gomez

I think your code is OK but remember this...
Neural networks doesn't have a procedure or metodology for an aplication, you need to try differents things according to your objetive, i'll give you some basic suggestions:

1. - Try with another NN structure, choose another arquitecture, for example 2 layers with 5 neurons each one:
net = newff(pt,t,[5,5]);

2.- Get down your performance goal (remember it's a cuadratic error)
net.trainParam.goal = 0.000001; % or more

3.- Use neural networks GUI in MATLAB, this is useful for better understanding. you can modify easily the structure and some parameters.
Write "nntool" in the command window,

4.- To use and visualize your net in simulink as blocks, use the command "gensim(net,-1)" (net is the net's name)
this is useful for analize each node of your net

for example i did this:

pt = random(10,7) % pt=input
t = [4 9 16 25 36 49 64]; % t = target

net = newff(pt,t,[5 5]);
net.trainParam.goal = 0.01;
net = train(net,pt,t);
y = sim(net,pt);

y =
19.8006 8.9843 16.0019 25.0058 16.8919 49.0029 63.9999

t = [4 9 16 25 36 49 64]; % t = target

OK it wasn't the best result haha.. but you need to modify some things and try and try until you are satisfied.

I hope this were helpful for you..


Comment only
27 Jul 2011 saurabh mishra

I am new to neural networking.I want train my neural network for pt = [10x7 array],but it is not getting trained.However for pt = [10x4 array] it is being trained properly. Can anybody tell me what is the problem with this code.

pt = [10x7 ] array; % pt = input

t = [4 9 16 25 36 49 64]; % t = target

net = newff(pt,t,10);

net.trainParam.epochs = 500;

net.trainParam.goal = 0.01;

net = train(net,pt,t);

y = sim(net,pt);

Thanks in Advance.

Comment only
22 Feb 2010 Victor Gomez

well, i installed MATLAB 32-bits version instead of 64 bits version which doesn't have the LCC compiler... with this it works =)

Comment only
19 Feb 2010 Victor Gomez

Hi,I need help! I can't simulate the demo file or use any block... for instance when i run the demo it send me this message: "Error in S-function 'anndemo/GRBF/Mran': S-Function 'emran8' does not exist."... I suppose i need the code source "emran8.m", is it true? can anybody help me?... I'm using MATLAB 2008a in Windows vista 64-bits.. thanks!

01 Nov 2009 Sinan

Sinan (view profile)

When I open "ann model", I receice an ERROR Message "Unable to load model file due to presence of characters that are not supported in the current character encoding"...
Please ,can anybody tell me why?

Comment only
28 Jul 2009 Chan-Yun

The blocksets are considerably beneficial to my application. Can I ask further for a more detailed descriptions or references of the function block "GRBFNN"? There are many parameters alone with the block. As you know, with improper parameter settings, the block may be used unsatisfactory and lead to an incorrect result.

Comment only
31 May 2009 Ahmed Hakim

please help me

Comment only
19 May 2009 Surendra Dhakal

I am a beginner in ANN and going through this code for some basic knowledge of RBF. I need to degin a RBF network(with gaussian function) for 22 inputs and 6 outputs. The problem is about the classification of breast cancer types. The 22 inputs are the features extracted from the given breast image(mammogram) and 6 outputs are the different cancer types. The second stage network is also needed with 2 or 3 outputs also(cancer stages). It would be great if you could manage some time to help me this with matlab code.
Thanks in advance!!

Comment only
28 Aug 2008 Ahmet Shala

Very good work

24 Apr 2008 suresh kumar  
27 Feb 2008 mohammed abu mallouh

exactly what Simulink tool box is missing.Excellent work hope to see it soon as part of the NN toolbox and see more examples

16 Jan 2008 Donovan Parks

Demo does not run out of the box. The GRBF block is missing. Once I fixed this, errors still occurred.

11 Jan 2008 ilyas mohammad  
09 Dec 2007 ali sahebi

I dont know yet!

Comment only
07 Dec 2007 amit singh  
08 Sep 2007 Mario Gennaro

His work is Eccelent!!!

21 Feb 2007 Lazhar Bilel  
09 Jan 2007 Nistor Grozavu  
02 Jan 2007 SURYA RAJU  
25 Oct 2006 Tansel Yucelen

Sir, I think it is fair, because you did not give codes (of course), but I can not change the codes for my purpose (for ex. I want to change one code to make optimal neural control). you can .m file codes if available to my e-mail address.

22 Oct 2006 mahendra reddy  
30 Sep 2006 husain ahmed

respected sir, i m a lecturer in engineering college. For project i need the neural network programming & how i can imliment the ann in control systems. please help me

21 Aug 2006 Piyush Khatavkar

Respected Sir,
I am piyush Khatavkar studying in final year chem engg. and doing my project on ann. actually i need some help regarding ann documentation

24 Jul 2006 malihe yadegari  
31 Mar 2006 rosa rapisarda  
20 Feb 2006 nallu swamy


17 Jan 2006 Alex Tolly

It is an excellent toolbox

28 Nov 2005 Lisandro Curia


19 Nov 2005 vankara partha saradhi  
11 Oct 2005 PRAVAT ROUT  
04 Oct 2005 Morteza Mohebbi

With thank you, I want to know how can I learn RBF neural network with my adaptive law for weights that is not the same as your adaptive law.

01 Jun 2005 ben mok

i need if you help how to combine in matlab simulink an rst adaptive conntroller (with pole placement) with rls identification of any system. thank you

Comment only
13 May 2005 siba mahapatra


26 Feb 2005 mohit goyal  
16 Feb 2005 tofik riyadi

i need it

Comment only
09 Feb 2005 parashuram uppar


01 Feb 2005 Masih Hosseini

I encourage you to use DCS boxes.
They are really nice.


It's very ,uch useful for my projects

25 Jan 2005 Masih Hosseini  
13 Jan 2005 éöó ààï  
04 Jan 2005 my Love

it's very nice

07 Dec 2004 AJAY AKASAPU  
24 Sep 2004 AN Seong-Jun

very good for student..^^

09 Aug 2004 soko guru

It's a nice toolbox even if i haven't tried it.

Comment only
07 Aug 2004 Saeed Beyty

a very well written and useful blockset.
a must see for all NN lovers.

10 Jul 2004 Kianoush Nazarpour  
10 May 2004 Santosh Dasika

Can u plz post the codes for the recurrent neural networks, i.e., from the base, writing s code using an algorithm rather than using a user defined algorithm?

Comment only
12 Mar 2004 Aditya kumar

I require the mtlab code for Counter propagation network and Dynamic supervised Forward propagation network

Comment only
16 Feb 2004 Abdel heliel  


14 Dec 2003 E. A. Capuano  
25 Nov 2003 santosh chowhan

preliminary source code for neural networks
in c/c++/MATLAB

16 Oct 2003 shehzadi .


07 Oct 2003 jorge cano

Excellent work.

06 Jul 2003 Alan Carter

Very fine piece of work.

23 May 2003 Anatoly Radchenko  
Comment only
22 May 2003 puya afshar  
26 Mar 2003 rg gowda  
26 Mar 2003 rg go  
16 Jan 2003 teguh prihantoro

its good for all student in university that interest about neural network using mathlab.

Comment only
20 Nov 2001

info.xml file added for R12
and some other very minor

19 Mar 2002

The code for emran and dcs networks has been widely cleaned and refactored.
A minor bug causing errors in Matlab 6.1 has been fixed.

02 Jul 2002

Stabilizing terms (somewhat similar in a way to "Sigma modifications" and "forgetting factors") have been added in both Adaline and EMRAN. Some typos in the EMRAN help text have been corrected as well.

12 Feb 2003

Very small modifications for MATLAB 6.5 (conversion to real before calling some s-functions).

02 Jul 2003

Some fairly big changes :
-) Every network has MIMO capability
-) The help files have been completely rewritten.
-) The demo is also somewhat improved.

17 Dec 2003

Minor changes in the demo. Please email me if you need the source.

17 Dec 2003

Minor changes in the demo. Please email me if you need the source.

12 May 2005

Renamed everything lowercase

12 May 2005

Removed dir structure from zip file

23 Aug 2006

Step by step instrucions on how to train the ERMAN network have been included, as well as a support example.

07 Feb 2007

Refined info.xml file.

04 Jun 2007

Only the best networks (one per class) have been retained, names have been simplified, dependency on the smxl library has been removed, all S-Functions are now written in C, and weight limiting mechanisms have been added.

23 Oct 2007

Recompiled mex files with matlab 7.1 so that everything works fine with newer versions requiring the .mexw32 extension. The .dll files are retained to the benefit users working with versions prior to 7.1, other users may delete them.

Contact us