Question
[inputfilename, filePath] = uigetfile({'*.slx';'*.xls';'*.xlsx'},'Select File '); % check if file selected if isequal([inputfilename,filePath],[0,0]) errordlg('No File selected','File Error'); return % load the file else inputfilename= fullfile(filePath,inputfilename); % cehek if the file is excel formate if isempty(xlsfinfo(inputfilename)) errordlg('Excel Filename must be specified'); return else %input = [[0; 0] [0; 1] [1; 0] [1; 1]]; %output = [0 1 1 0]; sheet = 1; input = xlsread(inputfilename,sheet); sheet = 2; output = xlsread(inputfilename,sheet); net = newff(input,output, [5,1], {'tansig','purelin'},'traingd'); net.trainParam.show = 50; % The result is shown at every 50th iteration (epoch) net.trainParam.lr = 0.05; % Learning rate used in some gradient schemes net.trainParam.epochs =1000; % Max number of iterations net.trainParam.goal = 1e-3; % Error tolerance; stopping criterion %Train network net1 = train(net, input, output); end end ==================================================================== i read data from excel and have 2 sheet one as input(2 column) and the other as output(one column) but i get this error : *Inputs and targets have different numbers of samples.* but if i read the data from workspace like : input = [[0; 0] [0; 1] [1; 0] [1; 1]]; output = [0 1 1 0]; it work fine how i can resolve this and thanks in advance i want read data from excel and call Multi layer Perceptron
Expert Answer
Neeta Dsouza
PhD Expert
Answered Sep 17, 2026
After reading the EXCEL files you have to convert them to MATLAB matrices with sizes
[ I N ] = size(input) [ O N ] = size(target)
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related neural networks Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →