Plotting with dates and timesteps

조회 수: 11 (최근 30일)
Jelle
Jelle 2012년 7월 2일
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!

채택된 답변

Walter Roberson
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개)

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by