X-axis Labeling

2 次查看(过去 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 CenterFile Exchange 中查找有关 Axis Labels 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by