strvcat doen not work.
3 views (last 30 days)
Show older comments
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
on 13 Jun 2017
Edited: Stephen23
on 13 Jun 2017
>> 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?
Answers (0)
See Also
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!