title: Matlab neural network error: Input 1 size does not match net.inputs{1}.size
body: <p>I have a 90×50 matrix that holds my train data. every row holds features extracted from input images of digits (90 images have been read - 10 images for every digits). First 10 rows are extracted from 10 images of digit <code>1</code>, the second 10 rows are extracted from 10 images digit <code>2</code>, and so on, hence <code>size(dataset,1) = 90</code></p>
  
  <p>Neural networks part of my code is shown below:</p>
  
  <pre><code>T=zeros(1,90);
  for  i=1:90
      T(i)=ceil(i/10);
  end
  setdemorandstream(491218382);
  net=fitnet(20);
  
  [net,tr]=train(net,datasetNormalized',T);
  </code></pre>
  
  <p>datasetNormalized is my dataset normalized in the [0 1] interval. T is target for network. 
  What I want to do now is get a new image of a digit, turning it into a 1×50 vector(m_normalized in this case) and guess with the help of my trained network which digit it is. I used the code below but it does generate errors:</p>
  
  <pre><code>[a,b]=max(sim(net,m_normalized));
  disp(b);
   msgbox(['digit is: ' num2str(b)],'Digit recognized','help');
  </code></pre>
  
  <p><strong>Error message reads like this:</strong></p>
  
  <pre><code>Error using network/sim (line 130)
  Input 1 size does not match net.inputs{1}.size.
  
  Error in Neural (line 92)
  [a,b]=max(sim(net,m_normalized));
  </code></pre>
  
  <p>Do you have any idea how I can get an output from the script that shows me which digit the input image was?
  By the way, the full script code is here for further reference: </p>
  
  <pre><code>clc
  clear
  close all
  
  numOfPhotos = 90;
  imgRows = 100;
  imgCols = 50;
  X = zeros(numOfPhotos, (imgRows * imgCols) / 100);
  
  %% Resize Images
  % myresize(imgRows,imgCols);
  
  % read train images
  datasetIndex = 0;    
  
  for i = 1:numOfPhotos/10
      for j = 1:numOfPhotos/9           
          datasetIndex = datasetIndex+1;
          im = imread(['resized_train_numbers\' num2str(i) ' (' num2str(j) ').jpg']);
          im = im2bw(im, graythresh(im));    
  
          c = 1;
          for g = 1:imgRows/10
              for e = 1:imgCols/10
                  s = sum(sum(im((g*10-9 : g*10),(e*10-9 : e*10))));
                  X(datasetIndex, c) = s;
                  c = c+1;            
              end    
          end
      end
  end
  
  datasetNormalized = zeros(numOfPhotos, imgRows*imgCols/100);
  %% Normalize dataset contents
  minDataset = min(min(X));
  maxDataset = max(max(X));
  for i = 1:numOfPhotos
      for j = 1:imgRows*imgCols/100
          datasetNormalized(i, j) = (X(i, j) - minDataset) / (maxDataset - minDataset);
      end
  end
  
  %%Neural network part
  
  T = zeros(1, 90);
  for  i = 1:90
      T(i) = ceil(i/10);
  end
  
  setdemorandstream(491218382);
  net = fitnet(20);
  [net, tr]=train(net, datasetNormalized', T);
  
  % Read input image for recognition
  
  newImg = imread('plate_1\1.jpg');
  newImg = imresize(newImg, [imgRows imgCols]);
  newImg = im2bw(newImg, graythresh(newImg));
  scrsz = get(0, 'ScreenSize');
  figure('Position', [1 1 scrsz(3)/3 scrsz(4)/2]),
  imshow(newImg);
  
  m = zeros(1, imgRows*imgCols/100);
  c = 1;
  for g = 1:imgRows/10
      for e = 1:imgCols/10
          s = sum(sum(newImg((g*10-9 : g*10), (e*10-9 : e*10))));
          m(c) = s;
          c = c+1;            
      end
  end
  
  %Normalize m contents
  m_normalized = zeros(1, imgRows*imgCols/100);
  for i = 1:imgRows*imgCols/100    
      m_normalized(i) = (m(i)-min(m)) / (max(m)-min(m));
  end
  
  [a,b] = max(sim(net, m_normalized));
  disp(b);
  msgbox(['digit is: ' num2str(b)], 'Digit recognized', 'help');
  </code></pre>