I'm trying to write a symbolic function to simulate an electrical device's electricity usage. Since the electricity is billed different price at different time of the day, I wanted to write a symbolic function with a duty cycle of 0.125 (on 15 minutes, off 1h45 minutes). I thought it would be easy with matlab.
syms x fridge = 0; for ii = 0:12 fridge = fridge + heaviside(x-(ii*2)) - heaviside(x-(0.25+(ii*2))); endfplot(fridge,[0, 24])
There are some parts of the functions not plotting correctly, like
heaviside(x-6)-heaviside(x-6.25)
Any ideas what could be wrong?
EDIT: When I plot my function from 0 to 12, it seems to work fine but when plotted from 0 to 18 it stops working.
Best Answer