MATLAB Answers

How to fix the ticklabels - time series analysis?

조회 수: 2(최근 30일)
Nadezhda Dimitrova
Nadezhda Dimitrova 27 Apr 2019
댓글: dpb 5 May 2019
I have a question with regard to the xlables when plotting timeseries.
It is a timeseries analysis with about 5000 observations (t) and 20 constituencies (N).
I would like to have on the x-axis the labels of t/N instead of the number of the data point. Therefore, I calculated C = t/N and tried to use it as a xticklabels but it does not really work:
--> which is clearly not (1:5000)/20
Here is the code:
%% Calculating the concentration ratio C = t/N
for i = 1 : size(Data200018,1) % size = 4579
concentrationRatio(:,i) = i./NumberAssets; % NumberAssets = 20
hold on
ylabel('Average error','FontSize',12)
xlabel('Concentration Ratio','FontSize',12)
hold off
I know that it is probably simpler than I think but I can’t figure it out :) Many thanks in advance for any advices!

  댓글 수: 0

Sign in to comment.

채택된 답변

dpb 27 Apr 2019
편집: dpb 27 Apr 2019
Clearly, the ticklabels you wrote are (1:5000)/20. The first label is 0.05 --> 1/20, the second 0.10 --> 2/20, etc., etc., ...
Matlab did precisely what you asked it to... :)
The problem is the tick marks aren't every x value else't there would be 5,090 of must label only the ticks; per the documentation tick labels are just a 1:1 mapping of the input ticklabel values to the tick locations; if there are more labels than ticks the rest are ignored; fewer and the array is used from the beginning as many times as needed. Since your axis has 10 intervals there are 11 ticks and you labeled them with the values [1:11]/20
instead to label the actual ticks at 1/20th tick value

  댓글 수: 2

Nadezhda Dimitrova
Nadezhda Dimitrova 5 May 2019
Thanks a lot for the great explanation, @dpb!
It worked but in different lines as the dimensions of xticks and concentrationRatio were different. Very helpful, thanks!
dpb 5 May 2019
Oh...that was a cut 'n paste error...the divisor should have been/was intended to be the constant NumberAssets instead...

Sign in to comment.

추가 답변(0개)

Translated by