How to get comma separated list directly from table.Properties.VariableNames?

Example:

>> A = table({}, {}, {}, {}, {}, ...
             'VariableNames', {'Foo', 'Bar', 'Baz', 'Frobozz', 'Quux'});
>> vn = A.Properties.VariableNames;
>> isequal(vn, A.Properties.VariableNames)
ans =

 1

So far so good, but even if vnthey A.Properties.VariableNamesseem the same, they behave differently when you try to get a comma-separated list from them (using {:}):

>> {'Frobnitz', vn{:}}

 ans = 

     'Frobnitz'    'Foo'    'Bar'    'Baz'    'Frobozz'    'Quux'

>> {'Frobnitz', A.Properties.VariableNames{:}}

 ans = 

     'Frobnitz'    'Foo'

Is there a way to get a “comma delimited list” from A.Properties.VariableNames directly (i.e. without creating an intermediate variable such as vn)?

(In addition, is there a more reliable function than isequalfor checking the equality of cells in arrays? In the above example, vnthey are A.Properties.VariableNamesclearly not equal enough!)


, MATLAB, ( ) table, , dataset ( ). :

clear('A', 'vn');
A = dataset({}, {}, {}, {}, {}, ...
            'VarNames', {'Foo', 'Bar', 'Baz', 'Frobozz', 'Quux'});
vn = A.Properties.VarNames;
isequal(vn, A.Properties.VarNames)
{'Frobnitz', vn{:}}
{'Frobnitz', A.Properties.VarNames{:}}

( VariableNames VarNames; : ):

+4
2

isequal. vn A.Properties.VariableNames . ...

help dataset.subsref, , , , table:

:

   Subscripting expressions such as A.CellVar{1:2}, A.StructVar(1:2).field,
   or A.Properties.ObsNames{1:2} are valid, but result in subsref
   returning multiple outputs in the form of a comma-separated list.  If
   you explicitly assign to output arguments on the LHS of an assignment,
   for example, [cellval1,cellval2] = A.CellVar{1:2}, those variables will
   receive the corresponding values. However, if there are no output
   arguments, only the first output in the comma-separated list is
   returned.

, A.Properties.VarNames{:}, dataset.subsref, {:} ., dataset.subsref.

- , , , A . , ( ) , ​​ , :

>> [{'Frobnitz'} A.Properties.VarNames]

ans = 

    'Frobnitz'    'Foo'    'Bar'    'Baz'    'Frobozz'    'Quux'
+2

, , -, vn. , -. , , TMW table .

isequal, . , , vn A.Properties.VariableNames .

+2

Source: https://habr.com/ru/post/1525088/


All Articles