Behaviour change of `isequal`

My question is about the call: isequal( 'a', "a" )
I noted that in Matlab R2018 this returns 0, whereas in Matlab R2020a this returns 1. In which release did this behaviour change?

 Accepted Answer

Fangjun Jiang
Fangjun Jiang on 1 Mar 2024
In R2018b, it returns TRUE already. See the "Compare Character Vector to String Scalar" section

5 Comments

And I can confirm this using release R2018b. [Putting the output in a block comment so I can run the which call later on.]
%{
>> version
ans =
'9.5.0.944444 (R2018b)'
>> isequal('a', "a")
ans =
logical
1
%}
To the original poster: can you copy and paste the exact code you're running (to identify if there's an extra space in the data or something like that) and the output of the following command into a comment on your question or on this answer?
which isequal('a', "a")
isequal is a built-in method % string method
That will help us determine if you've overridden the built-in isequal included in MATLAB.
Can you run this in R2018a, @Steven Lord? The oldest version available online is R2018b. I've searched its release notes but didn't find anything related.
>> version
ans =
'9.4.0.813654 (R2018a)'
>> isequal('a', "a")
ans =
logical
0
Okay, then the change happened in R2018b. There is a release note about string Arrays but no specific mention of isequal()
which isequal('a','a')
built-in (/MATLAB/toolbox/matlab/elmat/@char/isequal) % char method
which isequal("a","a")
isequal is a built-in method % string method
which isequal('a',"a")
isequal is a built-in method % string method
which isequal("a",'a')
isequal is a built-in method % string method
I indeed have R2018a too. Thanks everybody for the effort.

Sign in to comment.

More Answers (1)

As far as I understand, in both R2018b and R2020a version results return logic 1, not different as you said.
  • R2018b
  • R2020a
Note:
For Inputs to be compared (as separate arguments) A,B, the documentation has the following description(R2018 and R2020 are both identical):
String scalars and character vectors containing the same sequence of characters are equivalent.
-------------------
Latest R2023b
isequal('ab',"ab")
ans = logical
1
-------------------------Off-topic interlude, 2024-------------------------------
I am currently looking for a job in the field of CV algorithm development, based in Shenzhen, Guangdong, China,or a remote support position. I would be very grateful if anyone is willing to offer me a job or make a recommendation. My preliminary resume can be found at: https://cuixing158.github.io/about/ . Thank you!
Email: cuixingxing150@gmail.com

Products

Asked:

on 1 Mar 2024

Edited:

on 27 Apr 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!