How to fit num2str into labeling ??
5 views (last 30 days)
Show older comments
Hi Guys
I have trouble with using num2str for labeling x-axis. I'm doing this for get each number of SR on equivalent x-axis. Can anybody tell me what I'm doing wrong ? Now I get the same number of SR in all x-axis.
SR=[23 15 16 17 11] for i=1:length(SR) set(gca, 'XTick',1:length(SR), 'XTickLabel',{num2str(SR(i))}) end
Isa
0 Comments
Accepted Answer
Star Strider
on 22 May 2014
Use a cell array:
figure(1)
plot(1:5, (1:5).^2)
grid
SR=[23 15 16 17 11]
SRC = {SR};
set(gca, 'XTick',1:length(SR), 'XTickLabel',SRC)
You can eliminate the loop.
More Answers (2)
See Also
Categories
Find more on Axis Labels 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!