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에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by