Output of dependent variables in ode solver

1 view (last 30 days)
Hello, I am using ode15s to calculate the temperature of a room with air conditioning. Now I want to save the used cooling power of the chiller which is calculated as a result of the temperature. How can I add this value to the results? I´ve seen a different complex solutions, but there must be an easier way because in simulink you can just add an output to each variable you want to. Thanks in advance for your answers :)

Answers (2)

Torsten
Torsten on 8 Dec 2016
As a result from the call to ode15s, you get the temperature TEMP at different times in an array:
[T,TEMP]=ode15s(...)
Now just use a loop over the length of T to calculate cooling power of the chiller:
for i=1:numel(T)
TEMP_AKTUELL = TEMP(i,1);
COOLING_POWER_OF_THE_CHILLER(i)= function(TEMP_AKTUELL);
end
Best wishes
Torsten.

Christian Teicht
Christian Teicht on 8 Dec 2016
Thank you for your answer Torsten! The problem is, that there are some other factors making it impossible to calculate the cooling power out of the temperature array. That means the function is non invertible :-/ Is there an other possibility?
  4 Comments
Torsten
Torsten on 9 Dec 2016
Recalculate the value in OutputFcn from the solution y which is supplied in "keepvalues".
Best wishes
Torsten.
Christian Teicht
Christian Teicht on 9 Dec 2016
The calculation is quite complex (what I wrote here is just an example), it is not a problem because I can just copy and paste but I think it takes some time for the calculation. Although it works and I'm happy with it!
Thank you very much and have a nice weekend :) Christian

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!