Filter löschen
Filter löschen

Vertcat error on x-axis tick labels

3 Ansichten (letzte 30 Tage)
Erik J
Erik J am 21 Feb. 2017
Kommentiert: Erik J am 21 Feb. 2017
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'));

Akzeptierte Antwort

Jan
Jan am 21 Feb. 2017
Bearbeitet: Jan am 21 Feb. 2017
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.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by