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

  • Home
  • SEARCH
  • 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 6087525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:52:48+00:00 2026-05-23T11:52:48+00:00

This post was triggered by following discussion on whether cell arrays are normal arrays

  • 0

This post was triggered by following discussion on whether cell arrays are “normal arrays” and that vectorizaton does not work for cell arrays.

I wonder why following vectorization syntax is not implemented in MATLAB, what speaks against it:

>> {'hallo','matlab','world'} == 'matlab'
??? Undefined function or method 'eq' for input arguments of type 'cell'.

internally it would be equivalent to

[{'hallo'},{'matlab'},{'world'}] == {'matlab'}

because MATLAB knows when to cast, following works:

[{'hallo','matlab'},'world']

Cell array is an array of pointers. If both left and right side point to equal objects, isequal('hallo','hallo') returns as expected true, then why MATLAB still does not allow topmost example?

I know I can use strmatch or cellfun.

SUMMARY:

  • operator == which is required for vectorization in above example is eq and not isequal (other operators are < which is lt, etc.)
  • eq is built-in for numeric types, for all other types (like strings) MATLAB gives as freedom to overload this (and other) operators.
  • operator vectorization is thus well possible with cell arrays of defined type (like string) but not by default for any type.
  • function vectorization like myFun( myString ) or myFun( myCellOfStrings ), is also possible, you have just to implement it internally in myFun. Functions sin(val) and sin(array) work also not by witchcraft but because both cases are implemented internally.
  • 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-23T11:52:49+00:00Added an answer on May 23, 2026 at 11:52 am

    Firstly, == is not the same as isequal. The function that gets called when you use == is eq, and the scope of each of those is different.

    For e.g., in eq(A,B), if B is a scalar, the function checks each element of A for equality with B and returns a logical vector.

    eq([2,5,4,2],2)
    
    ans =
    
         1     0     0     1
    

    However, isequal(A,B) checks if A is identically equal to B in all aspects. In other words, MATLAB cannot tell the difference between A and B. Doing this for the above example:

    isequal([2,5,4,2],2)
    
    ans =
    
         0
    

    I think what you really intended to ask in the question, but didn’t, is:

    “Why is == not defined for cell arrays?”

    Well, a simple reason is: Cells were not intended for such use. You can easily see how implementing such a function for cells can quickly get complicated when you start considering individual cases. For example, consider

    {2,5,{4,2}}==2
    

    What would you expect the answer to be? A reasonable guess would be

    ans = {1,0,0}
    

    which is fair. But let’s say, I disagree. Now I’d like the equality operation to walk down nested cells and return

    ans = {1,0,{0,1}}
    

    Can you disagree with this interpretation? Perhaps not. It’s equally valid, and in some cases that’s the behavior you want.

    This was just a simple example. Now add to this a mixture of nested cells, different types, etc. within the cell and think about handling each of those corner cases. It quickly becomes a nightmare for the developers to implement such a functionality that can be satisfactorily used by everyone.

    So the solution is to overload the function, implementing only the specific functionality that you desire, for use in your application. MATLAB provides a way to do that too, by creating an @cell directory and defining an eq.m for use with cells the way you want it. Ramashalanka has demonstrated this in his answer.

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

Sidebar

Related Questions

The code at the bottom of this post is triggered by the following line
This post reference to the One Definition Rule. Wikipedia is pretty bad on explaining
This post on SO answers most of the questions I have (much thanks to
This post asks this question but doesn't really give an answer, so I thought
This post relates to this: Add row to inlines dynamically in django admin Is
This post started as a question on ServerFault ( https://serverfault.com/questions/131156/user-receiving-partial-downloads ) but I determined
This post is incorrectly tagged 'send' since I cannot create new tags. I have
So this post talked about how to actually implement url rewriting in an ASP.NET
From this post . One obvious problem is scalability/performance. What are the other problems
I this post , I've seen this: class MonitorObjectString: public MonitorObject { // some

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.