![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/357889/image.png)
Plot text with numbers
12 次查看(过去 30 天)
显示 更早的评论
Hello,
I have a question about a code. I have one file in which:
The first column has cell (text) arrays
The second has numbers (double)
In my plot x axis has text and y axis has numbers
I would like to plot x axis with y axis.
I am uploading this file.
How could I make it?
0 个评论
采纳的回答
Star Strider
2020-9-8
Try this:
T1 = readtable('test.xlsx');
vars = T1.Properties.VariableNames;
figure
plot(T1{:,2})
Ax = gca;
Ax.XTick = 1:numel(T1{:,1});
Ax.XTickLabel = T1{:,1};
xlabel(vars{1})
ylabel(vars{2})
producing:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/357889/image.png)
Note that table objects have specific indexing and variable reference requirements. The readtable function was introduced in R2013b.
.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!