problem in plotting dates

2 visualizaciones (últimos 30 días)
aggelos
aggelos el 4 de Sept. de 2012
hello ,
I'm trying to plot dates and the correspondings hourly electricity prices for a specific period by using the code
dateind = Date > datenum('July 2, 2008') & Date < datenum('Aug 13, 2008');
plot(Date(dateind), ElecPrice(dateind));
ylabel('$/MWh'); title('Electricity Prices from July 2, 2008 to Aug 13, 2008');
dates and electricity prices are of type double but my plot is not the right one . The problem is that i don't get the right graph shape. Here is a data sample... DATES
733408 733408 733408 733408 733408 733408 733408 733408 733408 733408 733408 733408 733408 733408 733408 733408 733408 733408 733408 733408 733408 733408 733408 733408 733409 733409 733409 733409 733409 733409 733409 733409 733409 733409 733409 733409 733409 733409 733409 733409 733409 733409 733409 733409 733409 733409 733409 733409 733410 733410 733410 733410 733410 733410 733410 733410 733410 733410 733410 733410 733410 733410 733410 733410 733410 733410 733410 733410 733410 733410 733410 733410 733411 733411 733411 733411 733411 733411 733411 733411 733411 733411 733411 733411 733411 733411 733411 733411 733411 733411 733411 733411 733411 733411 733411 733411 733412 733412 733412 733412
ELECTRICITY PRICES
59,4500000000000 49,5500000000000 44,1000000000000 43 44,1000000000000 43,9600000000000 53,1500000000000 45,5300000000000 52,5300000000000 56,2900000000000 61,5000000000000 59,6800000000000 62,3100000000000 58,4500000000000 55,6600000000000 57,8800000000000 73,1700000000000 94,4400000000000 76,6500000000000 73,1800000000000 71,2200000000000 62,5300000000000 54,5400000000000 55,5800000000000 82,3100000000000 75,1700000000000 68,1500000000000 68,2600000000000 70,1500000000000 83,0600000000000 79,2900000000000 91,3400000000000 96,4900000000000 101,570000000000 102,950000000000 105,790000000000 103,410000000000 98,7900000000000 90,5900000000000 94,6300000000000 118,470000000000 134,540000000000 124,840000000000 122,160000000000 114,460000000000 104,860000000000 84,6300000000000 77,8300000000000 99 98,9600000000000 101,310000000000 101,310000000000 109,990000000000 129,490000000000 159,560000000000 162,190000000000 168,830000000000 173,150000000000 158,660000000000 154,550000000000 140,090000000000 139,080000000000 133,750000000000 139,430000000000 144,860000000000 185,770000000000 184,270000000000 147 140,820000000000 145,610000000000 129,530000000000 125,720000000000 90,6100000000000 90,6000000000000 95,3500000000000 95,2500000000000 87,8300000000000 99,7500000000000 130 114,910000000000 114,470000000000 113,310000000000 109,490000000000 101,030000000000 99,6300000000000 96,7000000000000 91,1200000000000 94,3400000000000 119,440000000000 123,100000000000 110,590000000000 106,020000000000 103,750000000000 94,5600000000000 88,0800000000000 95,0600000000000 75,4900000000000 61,9500000000000 60,5000000000000 60,4900000000000
any help , please...
  2 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 4 de Sept. de 2012
why is there duplicates dates
aggelos
aggelos el 4 de Sept. de 2012
Dear Azzi , your question made me find what was going wrong. My data are hourly and my dates are daily . So the solution to my problem is how to convert for example my first date 733408 to 01-Jan-2008 01:00:00 my second date to 01-Jan-2008 02:00:00 and so on . Can you please help my with this?

Iniciar sesión para comentar.

Respuesta aceptada

Star Strider
Star Strider el 4 de Sept. de 2012
It suggest using the addtodate function:
DATES24 = [];
for Day = min(DATES):max(DATES)
for Hours = 1:24
DATES24 = [DATES24; addtodate(Day, Hours, 'hour')];
end
end
DATES24_Str = datestr(DATES24)
The nested loops are necessary because addtodate only takes scalar inputs.
  2 comentarios
aggelos
aggelos el 5 de Sept. de 2012
thank you very much Star Strider. It works fine.
Star Strider
Star Strider el 5 de Sept. de 2012
It is my pleasure to help!
Thank you for accepting my answer.

Iniciar sesión para comentar.

Más respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 4 de Sept. de 2012
Editada: Azzi Abdelmalek el 4 de Sept. de 2012
y0=2008;m0=1;d0=1
datestr(datenum(2008,1,1,(1:24*365*4+23),0,0),'dd-mmm-yyyy HH:MM:SS')

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by