Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

I am using matlab r2010a to design a neural network to model 13,440 samples of numeral data of 3 input variables and 1 target. When i try to train, i get the following message;Targets are incorrectly sized for network. Matrix must have 3 columns

Asked by winston on 28 Mar 2013

The following is the code i have used;

Data_Inputs = xlsread('tvdiary10080.xlsx'); Testing_Data = xlsread('tvdiary3360.xlsx'); Shuffling_Inputs = Data_Inputs(randperm(10080),1:4); Training_Set = Shuffling_Inputs(1:10080,1:3)% specify training set [1st - 21st] Target_Set = Shuffling_Inputs(1:10080,4) % specify target set [22nd – 28th] Testing_Set = Testing_Data(1:3360,1:3) % specify Testing set [1st - 21st] Testing_Target_Set = Testing_Data(1:3360,4) % specify Testing set, Target [22nd – 28th] [pn, ps] = mapstd(Training_Set); [tn, ts] = mapstd(Target_Set); MyNetwork = newff (pn,tn, [20] , {'logsig'}); MyNetwork.trainFcn = 'trainlm'; MyNetwork.trainparam.min_grad = 0.00000001; MyNetwork.trainParam.epochs = 1000; = 0.4; MyNetwork.trainParam.max_fail =20; %MyNetwork= newrb(pn,tn,goal,spread, mn, df); MyNetwork = train(MyNetwork,pn,tn); save(NetworkName,'MyNetwork'); y = sim(MyNetwork, testn); % simulate network y_again = mapstd('reverse',y, targets) % denormlized %Daily_Result = performance(y,t,'all', 'v') % calculate statstics

What am i doing wrong?





No products are associated with this question.

2 Answers

Answer by Greg Heath on 28 Mar 2013
Accepted answer

1. Learn how to format your submissions e.g., indent equations 1 space

2. Transpose your matrices (as explained in the documentation)

Thank you for formally accepting my answer


1 Comment

winston on 29 Mar 2013

Thanks Greg and sorry for the casual submission. But if i add the transpose apostrophe, the response i get is this;

>> [pn, ps] = mapstd(Training_Set.’); ??? [pn, ps] = mapstd(Training_Set.’); | Error: The input character is not valid in MATLAB statements or expressions.

>> [pn, ps] = mapstd(Training_Set ’); ??? [pn, ps] = mapstd(Training_Set ’); | Error: The input character is not valid in MATLAB statements or expressions.

>> [pn, ps] = mapstd(Training_Set’); [tn, ts] = mapstd(Target_Set’); ??? [pn, ps] = mapstd(Training_Set’); | Error: The input character is not valid in MATLAB statements or expressions.

Greg Heath
Answer by winston on 29 Mar 2013

I just discovered where i was going wrong! To transpose, the apostrophe on the laptop keyboard is not recognizable by Matlab. I had to copy a more straight one from the net and it was accepted;

 ’ - rejected.
' - accepted



Contact us