フィルターのクリア

varfun changes the variable names in the table

31 ビュー (過去 30 日間)
hamed amini
hamed amini 2022 年 8 月 18 日
編集済み: dpb 2022 年 8 月 20 日
decimate_func = @(x) x(1:data_step:end);
T1 = varfun(decimate_func,T);
T2 = T(1:data_step:end,:);
T is a table of double and string columns. Expected T1 to be te same as T2, however T1 modifies the column names by adding a "Fun_" to the variable names. why?

採用された回答

dpb
dpb 2022 年 8 月 18 日
編集済み: dpb 2022 年 8 月 20 日
Because you operated on it with a function and so it is NOT the same variable any more -- that is documented behavior. varfun doesn't know (or care) that the function only selects a given subset of the same variable and doesn't modify it. It ((varfun, that is) also doesn't try to parse the function name (since so often one uses anonymous functions amongst other reasons) to add to the variable name; it just uses 'Fun_' as the arbitrary identifier.
You can manually rename the variables if you wish, of course...
T2.Properties.VariableNames=T.Properties.VariableNames; % put original names back

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeArgument Definitions についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by