Heaviside duty cycle symbolic function
4 ビュー (過去 30 日間)
古いコメントを表示
anonymoushippo
2017 年 2 月 21 日
コメント済み: anonymoushippo
2017 年 2 月 24 日
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)));
end
fplot(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.
0 件のコメント
採用された回答
Nachiket Katakkar
2017 年 2 月 23 日
The fplot appears to miss certain values for the range of values you have specified. The reason for this apparent ambiguity is that the number of function evaluations is set to the default value of the " MeshDensity " parameter (23) and hence certain critical points seem to have been missed for the range [0,24].
To obtain correct results I would suggest increasing the MeshDensity value to 60:
>> fplot(fridge,[0, 24], 'MeshDensity', 60)
Setting the value to 61, ensures that the value of 1/2 (at x == 6) is correctly represented as well:
>> fplot(fridge,[0, 24], 'MeshDensity', 61)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Assumptions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!