creating vector arrays from data set

22 visualizaciones (últimos 30 días)
Chet Sharma
Chet Sharma el 12 de En. de 2018
Editada: Chet Sharma el 14 de En. de 2018
Hi I have an hourly data set of electric load by day. E.g. for each day of Jan'00; I have 24 hours of electric load.I would like to create 31 separate vectors of length 24 (for each hour of the day) to hold the demand data for each day.
Here's my attempt:
numRows = length(dataset);
j=1
for i= 1:16:numRows
[day.j]=ds2.Demand(i:i+16,1);
j=j+1
end
I'm not sure how to create the right index for the d's. It should look like; d1 = (Hour1, Hour2...Hour 24), first day of data d2 = (Hour1, Hour2, ....Hour 24) of the second day of data
and so on and so forth...
Any suggestions on how to go? Thanks! C
  5 comentarios
Chet Sharma
Chet Sharma el 13 de En. de 2018
Chet Sharma
Chet Sharma el 13 de En. de 2018
Given that the ultimate aim is to chart by the column dOw, would it not be possible to write something like: plot(ds2.Demand,ds2.Hour,ds2.dos==2); Ideally, a chart for each separate day is what I'll need....I'm sure there's an easy trick...finding it hard to find as I'm rather new.

Iniciar sesión para comentar.

Respuestas (2)

Ahmos Sansom
Ahmos Sansom el 13 de En. de 2018
Hey,
Maybe convert column 2 to matlab datetime t = datetime(X,'ConvertFrom','Excel')
Then you cold select the data where weekday = 6 or Hour = 21 etc.
find(weekday(t) ==6)
This will give the index and then you can plot the respective values.
  1 comentario
Chet Sharma
Chet Sharma el 13 de En. de 2018
Editada: Stephen23 el 14 de En. de 2018
Thanks sir - I tried this, and it seems to work:
delete(findall(0,'Type','figure'))
figure,hold on;
count=1;
x=linspace(1,24,24);
for i=1:24:744
plot(x,ds2.mwh(i:i+23,1));
% day{count}=ds2.mwh(i:i+23,1);
count=count+1
legend('show');
end
xlim([1 24]);
hold off;
count
Now, I just need to extend it for the entire dataset, which has 12 months.

Iniciar sesión para comentar.


Chet Sharma
Chet Sharma el 14 de En. de 2018
Editada: Chet Sharma el 14 de En. de 2018
I think all answeres were useful here...so do I accept all answers (that were not provided by me, I mean)?
On another note, I found this awesome API called "plotly" (for those of you smiling, please be patient...I'm very new and still discovering), and it makes some solid interactive charts!
delete(findall(0,'Type','figure'))
figure,hold on;
count=1;
x=linspace(1,24,24);
for i=1:24:744
plot(x,ds.load(i:i+23,1));
% day{count}=ds2.mwh(i:i+23,1);
count=count+1;
legend('show');
end
xlim([1 24]);
fig=fig2plotly(gcf);
hold off;

Categorías

Más información sobre Tall Arrays 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