0

I am looking for some code for the following matlab plot, which now I adjust the X-axis step size manually.

enter image description here

As can be seen, the step sizes of Axis are different. In the above case, I have like 600 data of 3 days, where about 100 data for Monday, 300 data for Tuesday, and 200 Data for Wednesday.

As described, I have different number of data in one step. Thus, I dont want to have the same step size on X-axis, which is achieved now manually.

Can any one help me with setting the step size or set the X-label with flexibility ?

Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
GeekCat
  • 309
  • 5
  • 18
  • 1
    You can always use time instead of samples as the value for the x-axis. It does not even need to be that properly done. Just define **1** as **one day** and then the data can be placed at eg, 1/300, 1/200, or whatever is the number of samples you have. – patrik Jan 29 '15 at 09:32
  • Thanks, I did not quite get you, but I want the different steps size, say Monday I have 100 data points, Tuesday I have 300 data points, Wed I have 200 data points, how I can adjust the X-Axis according to that ? Any code samples will be well appreciated. – GeekCat Jan 29 '15 at 09:38

1 Answers1

1

Step size depends on what unit you use. I can give an example where you use day as a fundamental unit. The following code need to be made simpler to work with but this shows the principle in an easy way.

time = [1/100:1/100:1, 1+1/300:1/300:2, 2+1/200:1/200:3];
data = [3*rand(1,100), 0.5*rand(1,300)-1, rand(1,200)+7];
plot(time,data);
patrik
  • 4,506
  • 6
  • 24
  • 48