How to add labels to the LEFT of a table
13 次查看(过去 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 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!