Is There an Inconsistency with How Unassigned Values are Filled After an Assignment into a Table?
이전 댓글 표시
Create an empty table
T = table;
Assign a string value to the third row a new variable
T.string(3) = "abc"
The values in rows 1 and 2 are assigned as <missing>. Same basic behavior with a datetime
T.date(3) = datetime
Do the same thing with a numeric
T.number(3) = 5
I was expecting the unassigned number values to be filled with the @doc:missing value that corresponds to a double, which is NaN. Alas, it fills in with zeros, so now we can't go back afterwards and find which were the missing values that were automagically filled
ismissing(T)
I realize that filling with NaN would be problematic if NaN is a valid entry that could be assigned to an element of T.number, but it seems like filling with NaN would be better than zero in the majority of cases and that it would be more consistent with the other data types.
Or perhaps it's intended that T.num(3) = 5 should fill with zeros to consistent with how Matlab initizalizes unassigned elements of vectors?
x(3) = 5
I think that's a typical use case, but I'm not sure that same paradigm follows for data arranged in a table.
채택된 답변
추가 답변 (1개)
T(3) = "abc"
U(3) = datetime('now')
x(3) = 5
So the filling is consistent with arrays.
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!