My intention is to run, online, a state machine that offsets the irradiation vector and energy price vector to formulate a simple strategy only based on producing from irratiation over a threshold and keep producing from grid at the cheapest grid hours with irradiation under threshold, to supply the remain demmand, only 1 day ahead. Attached files.
First: logical indexing inside a matlab function embedded in a stateflow chart didn't work for me, I got the next error: "Non-constant expression or empty matrix". I tried using find instead of directly comparing and got the error "FIND requires variable sizing" So i had to iterate with for loops inside the funcion to find the hours of grid-connected production.
In the calculur_irr state, I only want to pre-calculate the day-ahead strategy once a day. I tried scheduled stateflows but keeping track of simulation time with the "clock" block was a disaster since the event was ignored, the once a day signal (using mod() or rem()).
So... in the calculur_irr state if you uncomment the second command, and comment the first, you'll se my final error "Illegal use of a matrix or vector type where a scalar was expected" where I tried everything, there's something I'm not seeing but I'm stuck.
The code of the embedded functions are quite simple, can someone help me?
Thanks in advance.