strvcat doen not work.

3 views (last 30 days)
Marcus Vinicius Pereira de Souza
Edited: Stephen23 on 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 Comment
Stephen23
Stephen23 on 13 Jun 2017
Edited: Stephen23 on 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?

Sign in to comment.

Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!