フィルターのクリア

How to change the values of X axis and Y axis?

32 ビュー (過去 30 日間)
Alan
Alan 2011 年 9 月 26 日
I want to change the values of X axis and Y axis when I plot a Graph, i.e, put the correct numbers instead of the matrix points. thanks

採用された回答

UJJWAL
UJJWAL 2011 年 9 月 26 日
Hi, I was not able to get your question clearly. Is this what you are asking ?
t = 0:0.01:2;
y= sin(t);
figure(1);
plot(y)
figure(2);
plot(t,y);
In the above code plot(y) will plot y with respect to the matrix points that is the matrix indices. The second plot that is plot(t,y) will plot it with respect to the corresponding values in t and you will see the actual numbers on the x-axis. Is that what you are asking ??
Happy To Help
UJJWAL

その他の回答 (2 件)

Jessica Beltran
Jessica Beltran 2011 年 10 月 13 日
Well, this may work for you.
If you have for example:
x = [1 2 3 4 5 6 7 8 9 10]; y=[.1 3 4 .2 5 1 7 3 1 0];
And you want to be able to manipulate the x-axis as you like, you can do this:
set(gca,'XTick',[1 5 9 10] ); %This are going to be the only values affected.
Then..
set(gca,'XTickLabel',[4 8 15 21] ); %This is what it's going to appear in those places.
  1 件のコメント
Jessica Beltran
Jessica Beltran 2011 年 10 月 13 日
I forgot to put plot(x,y) before the set

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


the cyclist
the cyclist 2011 年 9 月 26 日
I'm not sure I understand what you want, so you might want to provide more specific detail. But I think you can do what you want by setting the 'XTick' and 'YTick' properties of the plot.
>> set(gca,'XTick', ... )
where you fill in a vector with the values you want in place of "...".
You might want to read "help get" and "help set" and this page about handle graphics: http://www.mathworks.com/help/techdoc/learn_matlab/f3-15974.html

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by