How to add labels to the LEFT of a table
7 ビュー (過去 30 日間)
古いコメントを表示
Let's say we have a random table
T = readtable('indoors.csv');
head(T,3)
ans=3×3 table
Time Humidity AirQuality
___________________ ________ __________
2015-11-15 00:00:24 36 80
2015-11-15 01:13:35 36 80
The way we have VariableNames as'time' 'humidity' etc written, I want similar labels on the y-axis
Except instead of regular labels, I was labels like 'x[n]' and 'h[x]', but without it actually solving or giving me a concatenation error.
How can I do this?
or even just get me on the right track without doing x[n] stuff, please
This is my goal:
Time Humidity AirQuality
___________________ ________ __________
x[n] 2015-11-15 00:00:24 36 80
h[n] 2015-11-15 01:13:35 36 80
0 件のコメント
採用された回答
Star Strider
2021 年 4 月 25 日
I’m not certain what you want.
Experiment with this —
Time = (datetime('2015-11-15 00:00:24')+hours(0:1.1:5.5)).';
Humidity = randi([1 100],size(Time));
AirQuality = randi([1 100],size(Time));
AirTable = table(Time,Humidity,AirQuality);
AirTable.Properties.RowNames = compose('x[%d]',1:numel(Time))
Alterrnatively, try this option —
AirTable.Properties.RowNames = compose('%s[n]','a'+randi([0 25],size(Time)));
.
3 件のコメント
Star Strider
2021 年 4 月 26 日
For only two rows, yes.
In that instance —
AirTable.Properties.RowNames = {'x[n]','h[n]'};
will work.
However, doing this —
xhvct = repmat({'x[n]','h[n]'},1,ceil(numel(Time)/2));
AirTable.Properties.RowNames = xhvct(1:numel(Time));
throws the error:
Duplicate table row name: 'x[n]'.
So, each row must have a unique row name, however you choose to define them.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Tables についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!