Return function doesn't work after a while
显示 更早的评论
Good afternoon everybody,
I have an issue with one of my Matlab script. I will try to explain clearly my problem. I've linked the software TRNSYS with Matlab. Basically, TRNSYS calls a Matlab script at every timestep. When I wrote the Matlab code, I've used a small simulation time (only 48 hours) in order to check that everything was working. And it was working without any problem.
However, when I increases the simulation time, the simulation blocked after many hours (the number of hours depends on the starting time of my simulation, but I don't find any logic. Sometimes it stops working after 50 hours, sometimes after 600...). I've used the dbstop function to understand the problem, and I think that the problem comes from the "return function" at the end. Indeed, during the first hours, the return function works without any problem: at each time that the program reaches the return, the timestep of my simulation increases. However, after a while, when the program reaches the return, the program come back to the beginning of the matlab program without increasing the TRNSYS simulation timestep.
Since the return is not dependent of any other value (from my knowledge), I really don't understand how it may work perfectly at the beginning and stop working after. Do you have any idea for me of what it may come from ?
Thanks a lot for your time and your help ! Hélène
3 个评论
Geoff Hayes
2017-1-30
Hélène - can you tell us more about what your function does? Do you increment a counter indicating which tilmestep you are at? How often do you call your function? Are you keeping track of an array of data which gets updated at each call to your function?
You may want to provide a small sample of your code so that we can get a better idea of what is happening.
Hélène T.
2017-1-30
Hadi Ramin
2018-6-3
Hello, I am going to perform whole building optimization using heuristic algorithm in matlab and Transys. do you know how to connect matlab and transys? Thank you so much
回答(2 个)
Jan
2017-1-30
I can guarantee, that return is not the problem. I promise this.
You wrote:
However, after a while, when the program reaches the return, the program come back
to the beginning of the matlab program without increasing the TRNSYS simulation timestep.
Then this is a problem in TRNSYS? The shown script reaches the final return, but the calling function does not proceed as expected?
We also have this problem an we changed "Calling Mode" in Tab "Parameter" of the TRNSYS Type 155 from "0" (Standard iterative component) to "10" (Non-iterative component). According to the TRNSYS Programmers Guide this is suitable for controllers. And for us it worked so far we can see until now. We also implement some control algorithms to control energy systems for longterm simulation of at least one year. As I've seen from your code this is nearly the same. So have you already tried this?
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!