Home » Programming » Simple ANN for Function Approximation

Simple ANN for Function Approximation

ANNAn artificial neural network (ANN) is an information-processing system that has certain performance characteristics in common with biological neural networks. A very important feature of these networks is their adaptive nature where “learning by example” replaces “programming” in solving problems. ANNs are used as computational machines for wide variety of problems. Such as pattern classification, speech synthesis and recognition, adaptive interfaces between humans and complex physical systems, function approximation, image compression, associative memory, clustering, forecasting and prediction, combinatorial optimization, non-linier system modeling, and also in control .

The following code is a simple implementation of ANN for function approximation using. In this code I just used available MATLAB functions to implement ANN. We can develop our own code to implement ANN in MATLAB.  (See also here with GUI)


%                 Function Approximation Using ANN

% ————————————————————————-

% By     : Sutrisno Ibrahim

% Contact: sutrisno_link@yahoo.com             Last update: May, 2015


%  Funtion to be approximate y=f(x)=1+sin(5*pi*x/4);



% Plot the function


% Create ANN and train it


net = newff(x,y,N_layer); %

net.trainParam.lr = 0.01;

net.trainParam.epochs = 300;

net.trainParam.goal = 1e-5;

net = train(net,x,y);

% Simulate

y_ann = sim(net,x);

% Plot the results

hold on

plot(x,y_ann,’o’,’color’,nnred), xlabel(‘x’),ylabel(‘f(x)’);

title(‘Function Approximation Using ANN’);

hold off



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s