MATLAB: Train and Simulate Newff

train and simulate newff

Dear,
Here below is a problem with requirements. I tried in same way as guided but unable to understand how to Train and then simulate using newff .
If any one please help/guide me in this regard.
Thanks
Question: Training a feedforward NN to learn the surface given by the expression:
z = cos (x) sin (y)
defined on the square−2≤x≤2,−2≤y≤2.
>>>>> You can generate and plot the above defined surface using the following Matlab commands:
x = -2:0.25:2; y = -2:0.25:2; z = cos(x)'*sin(y); mesh(x,y,z)
xlabel('x axis'); ylabel('y axis'); zlabel('z axis');
title('surface z = cos(x)sin(y)');
2.3. Now the tasks for this assignment:
(a) Design a two layer (one hidden and one output) feedforward network to learn target function.
(b) Try learning the function using different number of NN units in the hidden and output layers. E.g. 25 in the hidden and 15 in the output, and then repeat the experiment twice, with reduced and increased number of units in the two layers. For each of the three cases show (using plot) and comment on the performance of our NN by employing the function “sim” as in the tutorial part of this assignment.
(c) Show and comment on the system performance by repeating the above experiment (just once) using Levenberg-Marquardt and Gradient Descent learning schemes.

Best Answer

It looks like this is a straightforward curve-fitting problem which will output z given the 2-D input [ x; y ]. With [-2:0.25:2] line grids of 17 points per line, N= 17^2 = 289 points.
[ 2 289 ] = size(input)
[ 1 289 ] = size(height)
Therefore use
FITNET (calls feeforwardnet) or the obsolete NEWFIT (calls NEWFF)
The single valued output z for the point (x,y) using FITNET is
z = net([x;y])
using NEWFIT it is probably
z = sim(net,[x;y])
Hope this helps.
Thank you for formally accepting my answer
Greg