readtableの使い方
32 views (last 30 days)
Show older comments
readtableの使い方についてお尋ねします。
1)下はHelpに示されているreadtableの使い方ですが、Tのformatはどういう形なのですか。
"スプレッドシートから、最初の行に変数名、最初の列に行名が含まれるテーブルを作成します。 "とありますが、Tはcellごとにformatがちがうのでしょうか。
2)>> plot(T(1:10, 3))とやるエラーになります。
エラー: tabular/plot (line 156)
'table' クラス用のプロット メソッドはありません。ドットの添字または中かっこの添字を使用して、変数を table にプロットし
てください。
expample
T = readtable(filename)
T=5×6 table
LastName Gender Age Height Weight Smoker
____________ ______ ___ ______ ______ ______
{'Smith' } {'M'} 38 71 176 1
{'Johnson' } {'M'} 43 69 163 0
{'Williams'} {'F'} 38 64 131 0
{'Jones' } {'F'} 40 67 133 0
{'Brown' } {'F'} 49 64 119 0
宜しくお願いいたします。
0 Comments
Answers (2)
Hernia Baby
on 5 Jul 2022
Edited: Hernia Baby
on 5 Jul 2022
table型の問題ですね。
まず例を作ります。
T=[{'Smith' } {'M'} 38 71 176 1
{'Johnson' } {'M'} 43 69 163 0
{'Williams'} {'F'} 38 64 131 0
{'Jones' } {'F'} 40 67 133 0
{'Brown' } {'F'} 49 64 119 0 ];
T = cell2table(T)
plot関数を使うときは以下のようにしてください。
plot(T{1:5,3})
以下のように、コラムを指定することでも可能です。
plot(T,"T3")
変数名はPropertiesから取り出すことが可能です
MATLABでは候補が出てくるので、Tabキーがお勧めです
T.Properties.VariableNames
3 Comments
See Also
Categories
Find more on Other Formats in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
