フィルターのクリア

How to fit num2str into labeling ??

11 ビュー (過去 30 日間)
Isa Duran
Isa Duran 2014 年 5 月 22 日
コメント済み: Star Strider 2014 年 5 月 22 日
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

採用された回答

Star Strider
Star Strider 2014 年 5 月 22 日
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.
  1 件のコメント
Star Strider
Star Strider 2014 年 5 月 22 日
‘Thanks’
My pleasure!

サインインしてコメントする。

その他の回答 (2 件)

G PRAKASH
G PRAKASH 2014 年 5 月 22 日
use square([]) bracket instead of {}.
  1 件のコメント
Isa Duran
Isa Duran 2014 年 5 月 22 日
I have tried that, it still gives me the last SR number which is 11. So there are 5 x-labels who all are 11. I want to have the first label to the 23, the second to be 15 and so on...

サインインしてコメントする。


Isa Duran
Isa Duran 2014 年 5 月 22 日
Thanks

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by