Matlab "missing" values not clear

32 Ansichten (letzte 30 Tage)
Temi
Temi am 23 Mär. 2017
Beantwortet: Jan am 23 Mär. 2017
Matlab holds some types of "<missing>" values in its string array. For instance
b =
3×3 string array
"I" <missing> "MATLAB"
<missing> "love" "MATLAB"
"I" "love" <missing>
when I access each element of the array
b(1)
ans =
string
"I"
b{1}
ans =
I
b(2)
ans =
string
<missing>
b{2}
errormsg = Conversion of element 2 from missing to character vector is not supported.
what type of value is "missing", and why can't it simply be an empty character vector?
  2 Kommentare
Stephen23
Stephen23 am 23 Mär. 2017
@Temitope Akinpelu: how did you create the variable b ?
Walter Roberson
Walter Roberson am 23 Mär. 2017
Bearbeitet: Guillaume am 23 Mär. 2017

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Guillaume
Guillaume am 23 Mär. 2017
Bearbeitet: Guillaume am 23 Mär. 2017
what type of value is "missing"
From the user point of view it's a flag for missing data. How it is implemented should not concern you and is not documented. (And I don't mean that in a negative way. We, as users, should not have to care, it should 'just work')
and why can't it simply be an empty character vector I don't know if it's a deliberate decision from mathworks or an oversight. However, there are plenty of cases where a missing string is not the same at all as an empty string.
Note that missing is brand new as of R2017a. As is documented the curly braces syntax is a compatibility layer for these codes that rely on cell array of char arrays and you should try to avoid it. It is indeed a bit unfortunate that that compatibility layer breaks in case of missing, so if you want that changed create a bug report with mathworks.

Weitere Antworten (1)

Jan
Jan am 23 Mär. 2017
"Missing" means, that the string was not defined before. An empty string would be a defined string already. This is something completely different.
With cell arrays an equivalent method was implemented for cell arrays, but not visible from the Matlab layer:
C = cell(1, 5)
C{1}
Now the contents of C{1} is treated as empty matrix [], but internally the element contains a NULL pointer. From the MEX level this must be considered explicitely - with the advantage that it can be distinguished also.

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by