Vertcat error on x-axis tick labels

2 次查看(过去 30 天)
I cannot figure out why I keep getting the Vertcat error (Dimensions of matrices being concatenated are not consistent) when I try to set the XTickLables. The relevant code is below. Any help is much appreciated. I'm on 2014a.
[~,Ex,Cam,CF] = LoudnessModel_Chen2011(OuterEarOpt,f,lv, 0, 70, 10);
figure(1);semilogx(CF,10*log10(Ex),'r', 'linewidth',1.5);
ylim([0 120]);
xlim([0 10000]);
xx=title('SNHL', 'fontweight', 'bold','FontSize', 20);
P = get(xx,'Position');
set(xx,'Position',[P(1) P(2)+2.75 P(3)]);
xlabel('Frequency (Hz)', 'FontSize',22);
ylabel('Excitation Level (dB)', 'FontSize',22);
set(gca, 'XTick', [100 500 1000 2000 4000 8000]);
set(gca, 'XTicklabel', ['100'; '500'; '1000'; '2000'; '4000'; '8000']);
set(gca, 'FontSize', 15)
set(gca,'ticklength',2.5*get(gca,'ticklength'));

采纳的回答

Jan
Jan 2017-2-21
编辑:Jan 2017-2-21
Use a cell string instead:
set(gca, 'XTicklabel', {'100'; '500'; '1000'; '2000'; '4000'; '8000'});
Concatenating the strings tries to create this:
['100'; ....
'500'; ...
'1000'; ...
'2000'; ...
'4000'; ...
'8000']
and as the error message says, this char matrix has a different number of columns per row.

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by