Using date and time in MATLAB
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Adnan Jayyousi
am 19 Jun. 2022
Kommentiert: Peter Perkins
am 21 Jun. 2022
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 Kommentare
Akzeptierte Antwort
Peter Perkins
am 20 Jun. 2022
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 Kommentare
Peter Perkins
am 21 Jun. 2022
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.
Weitere Antworten (1)
Sulaymon Eshkabilov
am 19 Jun. 2022
(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"
...
Siehe auch
Kategorien
Mehr zu Data Type Identification finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!