Plotting with dates and timesteps

10 ビュー (過去 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 Center および File ExchangeGrid 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