File Exchange

image thumbnail


version (145 KB) by Giampiero Campa
Adaptive Neural Networks


Updated 14 Feb 2008

View License

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.

Cite As

Giampiero Campa (2019). ANN (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (74)


I appreciate for this file. Thanks to the author.
I want to use ADALINE block for a ball on beam balancing system as controller. I created simulink model of my system, but when I run it I receive this error: "Error in S-function 'Nonlinear_BOBNN/ADALINE/vrmult': S-Function 'vrmult' does not exist".
How can I solve it?


excellent sir.thanks for sharing these rare topics.

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...

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!

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.

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


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.


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

Mr Smart

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.

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..


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.

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

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!


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?


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.

Ahmed Hakim

please help me

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!!

Ahmet Shala

Very good work

suresh kumar

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

Donovan Parks

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

ilyas mohammad

ali sahebi

I dont know yet!

amit singh

Mario Gennaro

His work is Eccelent!!!

Lazhar Bilel

Nistor Grozavu


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.

mahendra reddy

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

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

malihe yadegari

rosa rapisarda

nallu swamy


Alex Tolly

It is an excellent toolbox

Lisandro Curia


vankara partha saradhi


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.

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

siba mahapatra


mohit goyal

tofik riyadi

i need it

parashuram uppar


Masih Hosseini

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


It's very ,uch useful for my projects

Masih Hosseini

éöó ààï

my Love

it's very nice


AN Seong-Jun

very good for student..^^

soko guru

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

Saeed Beyty

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

Kianoush Nazarpour

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?

Aditya kumar

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

Abdel heliel



E. A. Capuano

santosh chowhan

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

shehzadi .


jorge cano

Excellent work.

Alan Carter

Very fine piece of work.

puya afshar

rg gowda

rg go

teguh prihantoro

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


Replaced an older version of that was mistakenly reintroduced in October 2007. Now everything works out of the box. Please let me know of any more problems.

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.

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.

Refined info.xml file.

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

Removed dir structure from zip file

Renamed everything lowercase

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

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

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

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

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.

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.

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

MATLAB Release Compatibility
Created with R11.1
Compatible with any release
Platform Compatibility
Windows macOS Linux