What is the correct syntax to label Xticks with data from a cell array

5 次查看(过去 30 天)
I'm trying to plot (bargraph) a column vector of numeric data (double) against site names along the X-axis. I just can't find the right syntax. Help a beginner please! A =
2
4
6
8
B =
'STP 0'
'STP 1'
'STP 3'
'STP 2'

回答(2 个)

Matt Tearle
Matt Tearle 2011-3-10
x = 1:length(A);
bar(x,A)
set(gca,'XTick',x,'XTickLabel',B)

the cyclist
the cyclist 2011-3-10
bar([2 4 6 8])
B = {'STP 0','STP 1','STP 3','STP 2'}
set(gca,'XTickLabel',B)
Homework?

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by