フィルターのクリア

Creating copy of column in table

19 ビュー (過去 30 日間)
BA
BA 2022 年 7 月 18 日
コメント済み: BA 2022 年 7 月 18 日
So far, I've tried to do it with addvars, but I'm having troubles with addvars. I have attached my code and the associated dataset that I'm working on. It keeps telling me "Unrecognized function or variable 'General_Prompt_SurveyStartedDate'." but I've checked 5 times and the variable name matches exactly what I have in the table.
exampledataset = addvars(exampledataset, General_Prompt_SurveyStartedDate, 'Before', 'General_Prompt_SurveyStartedTime');
I'm not sure why its doing it but if someone can take a look, that would be great.
Thanks

採用された回答

Image Analyst
Image Analyst 2022 年 7 月 18 日
There is no General_Prompt_SurveyStartedDate variable. There is a COLUMN/FIELD of a table called that but that is different than being its own variable.
Try this:
fileName = 'exampledataset.xlsx'
exampledataset = readtable(fileName)
newColumnValues = exampledataset.General_Prompt_SurveyStartedDate; % Extract one column.
newColumnName = 'CopiedDate' % Give it a new name - whatever you want.
exampledataset = addvars(exampledataset, newColumnValues, 'Before', 'General_Prompt_SurveyStartedTime', 'NewVariableNames', newColumnName);
  1 件のコメント
BA
BA 2022 年 7 月 18 日
Thanks, it works!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by