Question
Hi all, I have a folder which contains 200 BMP images, I am reading all the images, converting each image into a vector and then trying to store these image vectors into a matrix. Following is the code which is self-explanatory, though it looks quite right however when i run the script it give me the following error. Subscripted assignment dimension mismatch. Error in Readallimages (line 16) immat(437580,k)=imtovector myFolder = 'C:\Users\Sana\Desktop\DermoscopyImages'; if ~isdir(myFolder) errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder); uiwait(warndlg(errorMessage)); return; end filePattern = fullfile(myFolder, '*.bmp'); bmpFiles = dir(filePattern); immat=zeros(437580,200); for k = 1:length(bmpFiles) baseFileName = bmpFiles(k).name; fullFileName = fullfile(myFolder, baseFileName); fprintf(1, 'Now reading %s\n', fullFileName); imageArray = rgb2gray(imread(fullFileName)); %Read image and convert to Gray imtovector=double(imageArray(:)); %convert 2D image into 1D vector immat(437580,k)=imtovector %Store image vectors into matrix imshow(imageArray); % Display image. drawnow; % Force display to update immediately. end Any sort of help in this regard would be highly appreciated. Thanks in advance
Expert Answer
Neeta Dsouza
PhD Expert
Answered Aug 11, 2026
You may run out of memory. Why do you think you need to do this? You may not have to. You may be able to just read in and process one image at a time.
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 deep learning Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →