Filter löschen
Filter löschen

Loop between dates using the value for that date

3 Ansichten (letzte 30 Tage)
André Bernal García
André Bernal García am 28 Mär. 2017
Beantwortet: Mikhail Skalyga am 4 Apr. 2019
Hi:
I want to create a loop but not depending on the position of the value in an array, I want to create it dependent on a certain time:
I manage to create a timetable with the data I want :
Im starting with Matlab and therefore I dont know if it is the best way or not to do this.
My aim is to do a loop in the following way. For example:
if true
for i= {2015-12-31 10:00}:{2015-12-31}
Pup=UP/1000
Pdown=DOWN/1000
Pelspot=ELSPOT/100
%Im not just dividing in the the code, i will get an output that I will store, but I want the ouput for that certain time)
end
My problem is that I dont know how to tell MATLAB, use the data for this certain date ( now is easy but after I will use a table with 52 000 values were dates are repeated and I want to be sure MATLAB links the DATE with the data in this loop).
Thanks in advance

Akzeptierte Antwort

Peter Perkins
Peter Perkins am 29 Mär. 2017
Probably a loop is not what you want. It's possible that you want to do something like this:
i = isbetween(datime.Time,'31-Dec-2015 10:00:00','1-Jan-2016 00:00:00'}
Pup=datime.UP(i)/1000
Pdown=datime.DOWN(i)/1000
Pelspot=datime.ELSPOT(i)/100
Hard to say without more to go on. You could also use timerange:
tr = timerange('31-Dec-2015 10:00:00','1-Jan-2016 00:00:00')
Pup=datime.UP(tr)/1000
Pdown=datime.DOWN(tr)/1000
Pelspot=datime.ELSPOT(tr)/100

Weitere Antworten (1)

Mikhail Skalyga
Mikhail Skalyga am 4 Apr. 2019
Oh, man, I am taking the same course at DTU right now. Have you found out how to loop over date eventually?

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by