Vertcat error on x-axis tick labels
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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'));
0 commentaires
Réponse acceptée
Jan
le 21 Fév 2017
Modifié(e) : Jan
le 21 Fév 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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Axis Labels dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!