I'm trying to design a storage system where excess energy goes into it. There is a cap of a maximum storage size for the system. I am struggling to work out how to code this in matlab.
开发者_如何学运维Currently im using a function similar to this
max_storage = no_tanks*tank_size
if cumsum(excess) > 0
storage = cumsum(excess)
elseif cumsum(excess) < 0
After that I am confused how to continue writing the code. Any help would be greatly appreciated
Attempt at mind-reading, while awaiting an update to the question.
To limit the storage size to max_storage
, you need to have some code like
storage = calc_storage(excess); % or whatever
storage = min(storage, max_storage);
Don't forget to finish your statements with ;
, and if you need to use cumsum(excess)
lots of times it is better to assign it to a variable rather than calculating it over and over again.
精彩评论