フィルターのクリア

X-axis Labeling

1 回表示 (過去 30 日間)
Stefan Azzopardi
Stefan Azzopardi 2018 年 4 月 19 日
回答済み: Wick 2018 年 5 月 2 日
Hi,
I am a new user of MATLAB. I managed to read a large excel sheet on Matlab, sorted the data and plotted the graph of the wanted data. The problem that I am experiencing is that I am trying to make the values of x-axis as a percentage. I have a variable of around 1000 integer which may increase as I add data. I have assigned a variable to check the length of variable so that I do not have to change it manually. The problem is that I need to assign the x-axis in terms of 10%, 20%... 100%. How can I do that without reducing data for the y-axis?
Regards
  1 件のコメント
Stefan Azzopardi
Stefan Azzopardi 2018 年 4 月 19 日
The following is the code for the x-axis
A=round(length(data),2,'significant');
d=0.1*A
e=0:d:A
f=e/A*100
set(gca,'xticklabel', f)
The x-axis is showing up till 90%. The length of 'data' is 16990, therefor A results in 17000. d results to be 1700. Value of f is from 0 to 100 but the plot is still showing to 90%

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

回答 (1 件)

Wick
Wick 2018 年 5 月 2 日
I think the problem has to do with the fact that when there are 1000 elements in an array, there are only 999 gaps between those values. So the way you're constructing things nothing ever ends up at eactly 100.
Does this do what you want?
x = 100*(0:(length(data)-1)) / (length(data)-1);
plot(x,data)

カテゴリ

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