Using date and time in MATLAB
4 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I used to make this kind of work with excel, but I was suffering excel limitations last months and I think MATLAB is more friendly for me because I've some previous experience with it, and because of the flexibility to change things without 10 meters long formulas :)
So, I've two excel sheets, one sheet contains the electricity tariff in my country, the tariff is dynamic i.e. it changes depending on the seasons, hours, days, and holidays.
I want to import the sheet that called "LoadProfile&Tariff" to MATLAB, then I want matlab to fill the "Tariff" column (now it's empty).
The "TOU - 2023" sheet contains the data of tariffs and the corresponding seasons and times, the tariff is divided into two modes, "Off peak" and "On Peak"
The off peak is lowest price at a given season.
The on peak is the highest price on a given season.
I've explored the internet for some examples without success, I would appreciate any example for applying some logics on dates, i.e. statements like "if" / "for" etc..
Any suggestions ?
Thanks in advance.
0 个评论
采纳的回答
Peter Perkins
2022-6-20
I'm having trouble following exactly what needs to be done, but I imagine you want to append variables to your LoadProfile&Tariff timetable (you are going to make it a timetable, right?) to specify season and on/off-peak for each timestamp. Then you can use a join to add the tariffs from a table with season and on/off-peak values. Not sure how everything is defined, seasons by month, on/off-peak by, don't know, time of day, day of week, holidays? datetime has all kinds of comparisons that will handle all that.
2 个评论
Peter Perkins
2022-6-21
That's pretty simple logic, easily implemented using datetimes. relational comparisons, isbetween, timeofday, etc.
I disagree that this is not a join operation. This: "so put the tariff X into tariffs column" absolutely is a join.
更多回答(1 个)
Sulaymon Eshkabilov
2022-6-19
(1) Import data into MATLAB:
DB = readtable('YOUR_MS_Excel_Data.xlsx', 'Sheet', 'LoadProfile&Tariff', 'Range','A2:B38');
(2) Create a logical array to identify which time is on-peak and which one if off-peak, e.g.
IND= find(DB.Var1>'1/1/2020 8:15:00'); % Check your imported data's time format and match with it
(3) Create another column in DB table specifying "on-peak" and "off-peak"
...
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Identification 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!