strvcat doen not work.

2 Ansichten (letzte 30 Tage)
Marcus Vinicius Pereira de Souza
Bearbeitet: Stephen23 am 13 Jun. 2017
Dear all, I need to generate some box plots. However, there are several long texts and I need to break in vertical lines. I am using the command strvcat and am not having success. The following is an example of my script:
X = rand(20,6);
boxplot(X);
str={strvcat('cos(x)','Line 2'), strvcat('cos(x)','Line 2'), strvcat('cos(x)','Line 2'),...
strvcat('cos(x)','Line 2'), strvcat('cos(x)','Line 2'),strvcat('cos(x)','Line 2')};
set(gca, 'XTick',1:6,'XTickLabel',str, 'FontSize',8,'FontWeight','bold')
Can I help me? Thanks a lot!
  1 Kommentar
Stephen23
Stephen23 am 13 Jun. 2017
Bearbeitet: Stephen23 am 13 Jun. 2017
What makes you think that strvcat does not work? It works perfectly when I try your code:
>> str{1}
ans =
cos(x)
Line 2
>> size(str{1})
ans =
2 6
Of course you should not be using strvcat anyway, as the documentation clearly states: "*Note:* strvcat is not recommended. Use char instead."
The real topic is that you apparently want multiple lines in the XTickLabels, something that is MATLAB version dependent. So if you actually read the help for your installed MATLAB version then you wold learn if newlines are supported in your MATLAB, and how. If you want us to help you, then please tell us in a comment: what version of MATLAB are you using?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by