%% Fit Regression Model and Plot Fitted Values versus Targets
% This example shows how to train a feedforward network and calculate and plot the regression between its targets and outputs.
% Load the training data.

[x,t] = simplefit_dataset;

% The 1-by-94 matrix x contains the input values and the 1-by-94 matrix t contains the associated target output values.
% Construct a feedforward neural network with one hidden layer of size 20.

net = feedforwardnet(20);

% Train the network net using the training data.

net = train(net,x,t);

% Estimate the targets using the trained network.

y = net(x);

% Calculate and plot the regression between its targets and outputs.

[r,m,b] = regression(t,y)
plotregression(t,y)

% Copyright 2020 The MathWorks, Inc.