How to assign sequence values to an specific column of a table?

2 ビュー (過去 30 日間)
Stephan
Stephan 2022 年 11 月 28 日
コメント済み: Fangjun Jiang 2022 年 11 月 28 日
I'm trying to assign values from 1 to 720 to a table I already created but I keep getting error.
size = [720 4];
Type = ["double","double","double","double"];
Names = ["Hours","PrEV","SoCEV","Gen"];
master = table('Size',size,'VariableTypes',Type,'VariableNames',Names);
With this I have the table but how can I assign a sequence of numbers from 1 to 720 to the column Hours?
  1 件のコメント
Fangjun Jiang
Fangjun Jiang 2022 年 11 月 28 日
size() is a function. Try not to use it as a variable name.

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

回答 (1 件)

David Hill
David Hill 2022 年 11 月 28 日
size = [720 4];
Type = ["double","double","double","double"];
Names = ["Hours","PrEV","SoCEV","Gen"];
master = table('Size',size,'VariableTypes',Type,'VariableNames',Names);
master.Hours=(1:720)'
master = 720×4 table
Hours PrEV SoCEV Gen _____ ____ _____ ___ 1 0 0 0 2 0 0 0 3 0 0 0 4 0 0 0 5 0 0 0 6 0 0 0 7 0 0 0 8 0 0 0 9 0 0 0 10 0 0 0 11 0 0 0 12 0 0 0 13 0 0 0 14 0 0 0 15 0 0 0 16 0 0 0

カテゴリ

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

タグ

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by