Error using == Number of array dimensions must match for binary array op.
조회 수: 2 (최근 30일)
이전 댓글 표시
myFolder = 'C:\Users\cse\Desktop\images';
% if ~isdir(myFolder)
% errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
% uiwait(warndlg(errorMessage));
% return;
% end
a=uigetfile('C:\Users\cse\Desktop\1.jpg');
filePattern = fullfile(myFolder, '*.jpg');
jpegFiles = dir(filePattern);
for k = 1:length(jpegFiles)
baseFileName = jpegFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
imageArray = imread(fullFileName);
figure(k),imshow(imageArray);
if(a==imageArray)
disp('yes');
end
end
댓글 수: 0
답변 (1개)
Bhaskar R
2020년 2월 14일
편집: Bhaskar R
2020년 2월 14일
You are comparing character array with image matrix that is why you got error
if(a==imageArray)
disp('yes');
end
% a - Char array
% imageArray - Image numeric matrix
I think you are trying to compare filenames so replace if condition as
if(strcmp(a,baseFileName)
disp('yes');
end
댓글 수: 2
Walter Roberson
2020년 2월 14일
uigetfile returns the name of a file, not the contents of the file. But imageArray is the contents of one of the files, not the name of a file.
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!