Reputation: 31
I want to write a mean value at certain points in time in a vector.
My simulation is running for a year and I want to calculate a mean value for every day.
I have a variable in what is written what day of the year it is: Real DoY;
For every second my simulation computes a value: Real value;
So now i want something like this:
for i:365 loop
while i==DoY loop
der(value_DoY_dummy) = value;
value_DoY[i] = value_DoY/(34*3600);
end for;
end while;
Of course, this is not working and I don't have any better idea. How can I achieve this?
Upvotes: 3
Views: 473
Reputation: 2310
Below is a code that sets the value of a variable at certain time intervals. Perhaps this will provide you with some idea of how to apply it to your case.
This question may also be helpful to you.
model log Result
Real value;
Real savedValue;
Real nextTime(start=1);
algorithm
value := time + 10;
when time >= nextTime then
nextTime := nextTime + 1.0;
savedValue := value;
end when;
end LogResult;
Upvotes: 2