Behaviour change of `isequal`

13 vues (au cours des 30 derniers jours)
tommsch
tommsch le 1 Mar 2024
Commenté : tommsch le 1 Mar 2024
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?

Réponse acceptée

Fangjun Jiang
Fangjun Jiang le 1 Mar 2024
In R2018b, it returns TRUE already. See the "Compare Character Vector to String Scalar" section
  5 commentaires
Fangjun Jiang
Fangjun Jiang le 1 Mar 2024
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
tommsch
tommsch le 1 Mar 2024
I indeed have R2018a too. Thanks everybody for the effort.

Connectez-vous pour commenter.

Plus de réponses (1)

cui,xingxing
cui,xingxing le 1 Mar 2024
Modifié(e) : cui,xingxing le 1 Mar 2024
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

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by