Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Hi,there is error showing that the variable is varying.Someone help me plz

1 Ansicht (letzte 30 Tage)
Dhanya Francis
Dhanya Francis am 23 Jan. 2016
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
for i=1:M
str=strcat('C:\Users\Dhanya Francis\Desktop\Project\',int2str(i),'.jpg');
eval('img=imread(str)');
subplot(ceil(sqrt(M)),ceil(sqrt(M)),i)
imshow(img)
if i==2
title('Training set','fontsize',18)
end
drawnow;
[irow,icol]=size(img);
img(irow,icol) ;
temp=reshape(img,irow*icol,1);
S=horzcat(S,temp);
  1 Kommentar
Image Analyst
Image Analyst am 23 Jan. 2016
S and temp don't have the same number of rows. In fact, S was never even defined before you tried to use it, or at least if it was, you didn't show that code.

Antworten (1)

Walter Roberson
Walter Roberson am 23 Jan. 2016
Do not use eval!
str = fullfile('C:\Users\Dhanya Francis\Desktop\Project\', sprintf('%d.jpg', i));
img = imread(str);
Your line
[irow,icol]=size(img);
is incorrect for any RGB image, and .jpg are almost always RGB images.
[d1,d2,d3,...,dn] = size(X), for n > 1, returns the sizes of the dimensions of the array X in the variables d1,d2,d3,...,dn, provided the number of output arguments n equals ndims(X). If n does not equal ndims(X), the following exceptions hold:
n < ndims(X) di equals the size of the ith dimension of X for 0<i<n, but dn equals the product of the sizes of the remaining dimensions of X, that is, dimensions n through ndims(X).

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by