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 719989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:42:25+00:00 2026-05-14T05:42:25+00:00

A = imread(filename, fmt) [X, map] = imread(…) The above is in the synopsis

  • 0
A = imread(filename, fmt)

[X, map] = imread(...)

The above is in the synopsis part of imread, which seems to say that the return value of a MATLAB function depends on how it’s called? Is that true?

  • 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-05-14T05:42:26+00:00Added an answer on May 14, 2026 at 5:42 am

    IMREAD function is defined as

    function [X, map, alpha] = imread(varargin)
    

    In your 2 examples A and X will be the same, but in the second case there will be additional variable map.

    There is a way in MATLAB to define variable output if you use VARARGOUT in function definition:

    function varargout = foo(x)
    

    So you can output different values based on some condition in the function body.

    This is a silly example, but it illustrates the consept:

    function varargout = foo(a,b)
    if a>b
        varargout{1} = a+b;
        varargout{2} = a-b;
    else
        varargout{1} = a;
        varargout{2} = b;
    end
    

    Then

    [x,y] = foo(2,3)
    x =
         2
    y =
         3
    [x,y] = foo(3,2)
    x =
         5
    y =
         1
    

    The output arguments can be even different data types.

    Another example with condition based on number of output variables:

    function varargout = foo(a,b)
    if nargout < 2
        varargout{1} = a+b;
    else
        varargout{1} = a;
        varargout{2} = b;
    end
    

    Then

    [x,y] = foo(2,3)
    x =
         2
    y =
         3
    x = foo(2,3)
    x =
         5
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I = imread('coins.png'); level = graythresh(I); BW = im2bw(I,level); imshow(BW) The above is an
When I run this code: >> I = imread('D:\Works\matlab\SecCode.php.png','png'); >> imshow(I); It always shows
How can I know if an image read with imread is binary in MATLAB
In writing some image processing routines in Matlab, I found that I don't know
I have an image in MATLAB: y = rgb2gray(imread('some_image_file.jpg')); and I want to do
I have an image in MATLAB: im = rgb2gray(imread('some_image.jpg'); % normalize the image to
I have a numpy array which came from a cv2.imread and so has dtype
I have to load colours value from *.png file in c. Something like imread
so I'm using the imread function in matlab and when I save the TIFF
I have a matlab script that converts the images from png to jpeg. However

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.