Hello Everybody!
I want to know how can I set the axis using interval, for example:
>> a = rand(10);
>> plot(a)
>> Min = 2;
>> Max = 4;
>> set(gca,'XLim',[Min:0.15:Max]) -> Doesn't work!!
I know that the correct syntax is "set(gca,'XLim',[Min Max])" but, I want to use interval.
Ideas?
Thank you!

 採用された回答

Ben11
Ben11 2014 年 7 月 30 日

2 投票

Maybe use XTick:
set(gca,'XLim',[2 4])
set(gca,'XTick',(2:0.15:4))

3 件のコメント

Vinicius Antunes
Vinicius Antunes 2014 年 7 月 30 日
Hi Ben11!
Work with "set(gca,'XTick',(INTERVAL))!
Thank you!
Image Analyst
Image Analyst 2014 年 7 月 30 日
編集済み: Image Analyst 2014 年 7 月 30 日
You can use the xlim() function instead of set:
xlim([Min,Max]);
set(gca,'XTick',[Min : 0.15 : Max]);
It's also advisable not to use Min and Max since there are built-in functions with almost the same name. If you ever forgot to capitalize, you may get unexpected results. I never use built in function names for my variables even if I do use a different case. You can thank people by "Accepting" their answer and voting for the answer also.
Stelios Fanourakis
Stelios Fanourakis 2019 年 5 月 13 日
Hi. How can someone estimate the average of y values for every interval of the x axis as you state it?

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

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 7 月 30 日

4 投票

set(gca,'xtick', your_interval)

2 件のコメント

Vinicius Antunes
Vinicius Antunes 2014 年 7 月 30 日
Hi Azzi Abdelmalek!
Work with "set(gca,'XTick',(INTERVAL))!
Thank you!
Stelios Fanourakis
Stelios Fanourakis 2019 年 5 月 13 日
Hi. How can someone estimate the average of y values for every interval of the x axis as you state it?

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

カテゴリ

製品

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by