creating vector arrays from data set
이전 댓글 표시
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
Jan
2018년 1월 12일
It depends on how your "data set" is represented. An Excel file? A vector? A table object? Maybe a simple reshape is the solution already. Remember not to create 31 separate variables, but use a matrix instead. See https://www.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval and https://www.mathworks.com/matlabcentral/answers/57445-faq-how-can-i-create-variables-a1-a2-a10-in-a-loop
Chet Sharma
2018년 1월 13일
Chet Sharma
2018년 1월 13일
Chet Sharma
2018년 1월 13일
Chet Sharma
2018년 1월 13일
답변 (2개)
Ahmos Sansom
2018년 1월 13일
0 개 추천
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
Chet Sharma
2018년 1월 13일
편집: Stephen23
2018년 1월 14일
Chet Sharma
2018년 1월 14일
편집: Chet Sharma
2018년 1월 14일
카테고리
도움말 센터 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
