Plotting with dates and timesteps
조회 수: 11 (최근 30일)
이전 댓글 표시
Here is part of my script:
%%Parameters
StartDate = '26-Jun-1992';
EndDate = '26-Jun-2012';
TimePlotSteps = 200;
data = xlsread('StockPricesClean(1).xlsx');
%%split data
dates = datestr(data(:,1) + datenum('30-Dec-1899'));
data(:,1) = datenum(dates);
StartI = find(data(:,1) == datenum(StartDate));
EndI = find(data(:,1) == datenum(EndDate));
Data.Dates.numb = data(StartI:EndI,1);
Data.Dates.str = datestr(Data.Dates.numb(:,1), 'dd/mm/yy');
Data.Closing = data(StartI:EndI,5);
clear data
TradeSignal(1:length(macdvec),1)=0;
% Create x-axis vector
x=1:length(TradeSignal);
% Plots with dates
figure(2)
subplot(311)
plot(x,macdvec,'r',x,nineperma)
set(gca, 'XTick',1:TimePlotSteps:length(x), 'XTickLabel',Data.Dates.str)
xlim([0 x(end)]);
title('Trading signals on MACD')
If I set my Timeplotsteps to anything other than '1' the x-axis only runs up to july 1992. however if i keep timeplotsteps to '1' the x-axis runs up to july 2012 as it is supposed to but the x-axis looks terrible due to the small steps on the x-axis. How can I solve this (I am a beginner in Matlab so simplicity is appreciated!!)
thanks!
댓글 수: 0
채택된 답변
Walter Roberson
2012년 7월 2일
편집: Walter Roberson
2012년 7월 2일
And remember, the number of elements in XTickLabel must be the same as the number of elements in XTick.
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!