Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9058695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:47:21+00:00 2026-06-16T14:47:21+00:00

I just want to iterate through an image array one by one but I

  • 0

I just want to iterate through an image array one by one but I can’t get it working, I get the errors below. I can show single images via imshow (a), but not iterate through an array.

Error using getImageFromFile (line 12)
Cannot find the specified file: “a”.

Error in imageDisplayParseInputs (line 74)
[common_args.CData,common_args.Map] = …

Error in imshow (line 198)
[common_args,specific_args] = …

Code

% Images
a = 'redsquare.bmp';
b = 'bluesquare.bmp';
c = 'greysquare.bmp';
d = 'yellowsquare.bmp';

% Array to display
t = [a b c d];

% Loop to display    
for n=1:length(t)
 imshow(t(n))
end

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T14:47:22+00:00Added an answer on June 16, 2026 at 2:47 pm

    You have several bugs in the code as it is.
    First, verify that the directory where the images are located is in Matlab’s path , or try adding the full path of the images locations.
    I’d recommend to use a cell array to contain all the file names. The way you’ve done it in the question is to concatenate all strings to one long one, that is

    t =
    
    redsquare.bmpbluesquare.bmpgreysquare.bmpyellowsquare.bmp
    

    So in the code change t to:

    t = {a, b, c, d}; % note the curly brackets
    

    In the loop, you need first to read the image to an array before showing it, therefor add an imread line. After reading the file onto an array (lets called that array im), you can use imshow to plot it. All in all, the code in the loop should be:

    for n=1:numel(t)
       im=imread(t{n}); 
       imshow(im);
    end
    

    Again, note that I used curly brackets {} for the imread line, that is the way to extract the cell element content.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I iterate through DataGridViewRow columns? I just want to get the number
I have a FormCollection and I just want to only iterate through the keys
Just want to ask can netbean IDE get connected to clearcase remote client server
I want to iterate through an array of objects <% @users.each do |user| %>
I have an STL map that I want to iterate through, and can't seem
Just want to ask if i can use Custom Validator in client side without
Just want to make sure one thing. In a windows machine (either a desktop
I need to iterate through a tuple in the template, but from the code
I am working in Visual Studio 2010, and I can go through and write
I know that I can get an array of all the children of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.