Plotting with dates and timesteps

10 vues (au cours des 30 derniers jours)
Jelle
Jelle le 2 Juil 2012
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!

Réponse acceptée

Walter Roberson
Walter Roberson le 2 Juil 2012
Modifié(e) : Walter Roberson le 2 Juil 2012
And remember, the number of elements in XTickLabel must be the same as the number of elements in XTick.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by