in plotting,instead of 'ro' its needed to show numbers

10 ビュー (過去 30 日間)
mohammad
mohammad 2011 年 9 月 22 日
In plotting,instead of 'ro' its needed to show numbers
for example:
plot([0:20],[0:20],'ro')
its needed shows numbers from 1 up 20 instead of 'ro'
and please also refer DOC of this, I can't find it

採用された回答

Daniel Shub
Daniel Shub 2011 年 9 月 22 日
The "o" in "ro" is not really a letter or a number. You best bet might be to use a loop and the text command ...
figure;
hold on;
axis([0, 20, 0, 20]);
for x = 0:20
h = text(x, x, num2str(x));
set(h, 'HorizontalAlignment', 'Center', 'VerticalAlignment', 'Middle');
end
  5 件のコメント
Daniel Shub
Daniel Shub 2011 年 9 月 22 日
Sorry, I missed that bit. After your code, you should be able to do:
for ipeak = 1:length(peakinds)
h = text(peakinds(ipeak), peakmags(ipeak), num2str(ipeak));
set(h, 'HorizontalAlignment', 'Center', 'VerticalAlignment', 'Middle');
end
mohammad
mohammad 2011 年 9 月 22 日
figure(1);
plot(1:len0,x0,peakInds,peakInds,'ro'),ylim([0 300]),xlim([2000 8500])
hold on
peakInds=peakInds(2:end);
peakMags=peakMags(2:end);
for ipeak = 1:length(peakInds)
h = text(peakInds(ipeak)+15, peakMags(ipeak), num2str(ipeak),'Color','r');
set(h, 'HorizontalAlignment', 'Center', 'VerticalAlignment', 'Middle');
end
ylim([0 400]),xlim([1000 8500])
hold off

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumeric Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by