MATLAB: Errors from the Neural Network Toolbox code

feedforward neural networkseries prediction

I'm trying to use a feedforward network to predict future values of a series. I create a set of inputs
value, previous value, previous previous value, associated data 1, associated data 2
for each value in the series data, and use
next value, value after next, value after that value
as the targets, to try and predict the next three values in the series.
I have set the net to train on all the data it is given, with no validation or test data, and train it on the first 1400 values in the series. That works. But when I create a new set of data that has 1553 rows of data and train the network on that, to look at the details of the out-of-sample performance, I get a series of errors from the Neural Network toolbox :
Error using bsxfun Non-singleton dimensions of the two input arrays must match each other.
Error in nnMATLAB.pc (line 24) pi = bsxfun(@minus,pi,settings.xoffset);
Error in nncalc.preCalcData (line 20) data.Pc = calcMode.pc(net,data.X,data.Xi,data.Q,data.TS,calcHints);
Error in nncalc.setup1>setupImpl (line 170) calcData = nncalc.preCalcData(matlabMode,matlabHints,net,data,doPc,doPd,calcHints.doFlattenTime);
Error in nncalc.setup1 (line 17) [calcMode,calcNet,calcData,calcHints,net,resourceText] = setupImpl(calcMode,net,data);
Error in network/sim>nncalc_setup (line 728) [calcMode,calcNet,calcData,calcHints,net,resourceText] = nncalc.setup1(calcMode,net,data);
Error in network/sim (line 275) [calcLib,calcNet,net,resourceText] = nncalc_setup(calcMode,net,data);
Error in network/subsref (line 16) otherwise, v = sim(vin,subs{:});
Error in question (line 44) outputs =net( ip );
————————————————————————————————- Code that gives the errors (cut down from the real code ) :
tab = readtable( 'e:\Adaptrade data\EURAUD daily.txt' ); %read time series data
nOp = 3; % number of net outputs
subTab = tab(1:1400,:);
[ startRow lastRow ip ] = historyBlock( subTab.Close, [ 1:2 ], 3 ); % sub-set of the data

[ startRow lastRow trend ] = historyBlock( subTab.ITrend, [ 1:2 ], 3 );
ip = horzcat( ip, trend );
startRow = startRow + 1;
lastRow = lastRow + 1;
targets = subTab.Close( startRow : lastRow ); % target first column is same-length closes starting one row later
for k = 1:nOp - 1
targets = [ targets subTab.Close( startRow + k : lastRow + k ) ]; % add same-length columns starting 1, 2, ... nOp - 1 rows forward
end;
ip = ip';
targets = targets';
net = feedforwardnet( 7 );
net = configure( net, ip, targets );
net.divideParam.trainRatio = 100/100;
net.divideParam.valRatio = 0/100;
net.divideParam.testRatio = 0/100;
[ net, tr ] = train( net, ip, targets );
outputs = net( ip );
[ startRow lastRow ip ] = historyBlock( tab.Close, [ 1:2 ], 3 ); % the whole data

[ startRow lastRow trend ] = historyBlock( tab.ITrend, [ 1:2 ], 3 );
ip = horzcat( ip, trend );
outputs =net( ip );
-----------------------------------------------------
historyBlock is a function that takes the series of data values and constructs a matrix with each row being a set of values to be applied to the net inputs, as described above.
With 1400 rows of input data,
[ startRow lastRow ip ] = historyBlock( subTab.Close, [ 1:2 ], 3 ); % sub-set of the data
[ startRow lastRow trend ] = historyBlock( subTab.ITrend, [ 1:2 ], 3 );
ip = horzcat( ip, trend );
....
[ net, tr ] = train( net, ip, targets );
outputs = net( ip );
works perfectly well, but when trying to apply a matrix with 1553 rows to the inputs of the trained net, the program fails.
[ startRow lastRow ip ] = historyBlock( tab.Close, [ 1:2 ], 3 ); % the whole data
[ startRow lastRow trend ] = historyBlock( tab.ITrend, [ 1:2 ], 3 );
ip = horzcat( ip, trend );
outputs =net( ip );
the above errors appear.
The historyBlock function is
function [ startRow lastRow block ] = historyBlock( history, offsets, skipRows )
% history = column vector
% offsets = vector of offsets from current row to the associated history rows
% [ 1 2 ] means each block row has the format
% [ history[ row ] history[ row - 1 ] history[ row - 2 ] ]
% the last skipRows of data are excluded
%
% history [ 1:3 ] skip 2 gives
% [1]
% [2]
% [3]
% [4] ................ [4] [3] [2] [1] startRow = 4
% [5] [5] [4] [3] [2] lastRow = 6
% [6] ................ [6] [5] [4[ [2]
% [7]
% [8]
startRow = max( offsets ) + 1; % history row that becomes row [1] of block
block = history( startRow : end - skipRows ); % column of row's actual value
lastRow = startRow + size( block, 1 ) - 1; % last row of history to be included in block
n = length( offsets );
for k = 1 : length( offsets )
n = offsets( k );
block = horzcat( block, history( startRow - n : lastRow - n ) ); % append a back history column for each offset
end;
end

Best Answer

Individual inputs and targets in the NN Toolbox are
COLUMN VECTORS, NOT ROW VECTORS !
[ I N ] = size(input)
[ O N ] = size(target)
Thank you for formally accepting my answer
Greg