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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:54:13+00:00 2026-06-13T03:54:13+00:00

I was just curious why Matlab can compare an empty matrix to a singleton

  • 0

I was just curious why Matlab can compare an empty matrix to a singleton matrix. In particular

>> [] == [1]

ans =

[]

It just seems odd that it would do that and I’m just wondering why it would do that. This also works for other comparison operations (<=, <, >=, >, !=). It gives an error if the size of the row or column is greater than one.

Thanks!

Edit: I also believe they do this for other operators, such as addition, subtraction, etc.

  • 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-13T03:54:14+00:00Added an answer on June 13, 2026 at 3:54 am

    [] (empty matrix) is considered a valid matrix representation of size 0x0 by MATLAB. From the documentation for the eq function, which is what gets called when you use operator == to compare matrices, the behavior is as follows:

    A == B compares each element of array A for equality with the
    corresponding element of array B, and returns an array with elements
    set to logical 1 (true) where A and B are equal, or logical 0 (false)
    where they are not equal. Each input of the expression can be an array
    or a scalar value.

    …

    If one input is scalar and the other a nonscalar array, then the
    scalar input is treated as if it were an array having the same
    dimensions as the nonscalar input array.

    In the comparison [] == [1], the left operand is non-scalar (isscalar([]) returns 0) while the right operand is scalar. So scalar expansion rules apply, and the scalar operand is expanded to the dimensions of the non-scalar operand (in this case 0x0), and the result is an empty matrix.

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

Sidebar

Related Questions

Just curious how are these implemented. I can't see where I would start. Do
Just curious, if django has already proven that auto-admin can be done well, why
Just curious, is there a format string I can use to output something like
Just curious how you would comment this line of code: string customerNm = customerNm.EndsWith(s)
Just curious, of the physical bits taken. I understand that the difference in size
Just curious, since google search uses a lot of JS and AJAX, would it
Just curious. My thought is that generated files have negligible overhead in terms of
Just curious, I've noticed that some php files have extension 'class.php' or 'html.php'. What
Just curious to know what the best practice would be for something like this:
Just curious about which of these would be faster? $('ul.dropdown a').first().click(function(event) { event.stopPropagation(); return

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.