I figured out a way to solve the problem by numerical approximation using FMINCON and implementing the "integral" and "derivative" constraints with the NONLCON option.
The trick is to approximate the change in energy by adding or subtracting the area by using "cumtrapz" for each iteration (W-h), and "diff" for approximating the rate of change. Then it becomes easy to create the constraints:
function [c,ceq]=objectivestorage(x)
MaximumEnergy = 3;
MinimumEnergy = 0.5;
InitialEnergy=MaximumEnergy/2;
M=x(1:24); % Choosing just the variables of the battery
RemainingEnergy = InitialEnergy-cumtrapz(M); %%%<<<< energy remaining!!!
RateRamp=diff(M); %%%<<<< Watt/hour battery
c=[RemainingE-MaximumEnergy; %EnergyRemaining<MaximumEnergy
-RemainingE+MinimumEnergy; %EnergyRemaining>MinimumEnergy
M-3; %Power<MaximumPower
-M-3; %Power>MinimumPower
RateRamp-1000; %Rate<MaximumRate
-RateRamp-1000;]; %Rate<MinimumRate
ceq=[];
end
This has solved my problems of defining derivative and integral constraints for nonlinear optimization problems. The shorter the time frame the better the numerical approximation. I hope this helps someone!