Using date and time in MATLAB
3 ビュー (過去 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 で Calendar についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!