Using date and time in MATLAB
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Adnan Jayyousi
le 19 Juin 2022
Commenté : Peter Perkins
le 21 Juin 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 commentaires
Réponse acceptée
Peter Perkins
le 20 Juin 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 commentaires
Peter Perkins
le 21 Juin 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.
Plus de réponses (1)
Sulaymon Eshkabilov
le 19 Juin 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"
...
Voir également
Catégories
En savoir plus sur Data Type Identification dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!