MATLAB: Display multiple image in one figure window using for loop displayimage my image database folder has images named 1.bmp,2.bmp..and so on i want to use for loop (1 to 5) and display five images in one window how to do it? Best Answer for K = 1 : 5 this_image = imread( sprintf('%d.bmp', K) ); ax = subplot(1, 5, K); imshow(this_image, 'Parent', ax);end Related SolutionsMATLAB: Open an image in another image Here is an example:im1=imread('peppers.png');im2=imread('football.jpg');im3=im1;im3(1:size(im2,1),1:size(im2,2),:)=im2;figure('color','w')imshow(im3) MATLAB: How to display multiple images in one figure window using for loop % Inputs: folder and file extension% Will plot all files with the chosen extension in the chosen folder folder = 'C:\Users\pittsl\Desktop\Matlab\train\cup';ext = 'png'; %extension, no dot% Get list of all filescontent = dir(folder);allfiles = {content.name};isExt = endsWith(allfiles,['.',ext],'IgnoreCase',true); % req. r2016b or later https://www.mathworks.com/help/matlab/ref/endswith.htmlfiles = allfiles(isExt);% Determine subplot layoutnImages = numel(files);dimN = ceil(sqrt(nImages));dimM = ceil(nImages/dimN);nrows = min(dimN, dimM);ncols = max(dimN, dimM);% Plot themfor K = 1:nImages this_image = imread(fullfile(folder,files{K})); ax = subplot(nrows,ncols, K); imshow(this_image, 'Parent', ax);end Related QuestionHow to index filenames correctlyImagesc hide one axisIs imshow() not showing the image correctlyIs the colormap not working as expected
Best Answer