What is the problem with the heaviside function?
12 ビュー (過去 30 日間)
古いコメントを表示
fun =
@(p,x)p(1)*heaviside(x-p(2))
Undefined function 'heaviside' for input arguments of type 'double'.
0 件のコメント
採用された回答
Star Strider
2015 年 9 月 10 日
Your function works for me. Do you have the Symbolic Math Toolbox?
If you don’t substitute a call to this one for the heaviside call:
hvsd = @(x) [0.5*(x == 0) + (x > 0)];
I tested both, they give equivalent results.
2 件のコメント
Star Strider
2015 年 9 月 10 日
編集済み: Star Strider
2015 年 9 月 10 日
Yes. The heaviside function is only in the Symbolic Math Toolbox. My function provides the same results, so you can use it instead. I abbreviated its name to ‘hvsd’ be sure it didn’t overshadow heaviside on my computer so I could test both of them. You can obviously name it whatever you want.
その他の回答 (1 件)
Thorsten
2015 年 9 月 10 日
編集済み: Thorsten
2015 年 9 月 10 日
The error means that Matlab cannot find the heaviside function. Try
which heaviside
to locate the function. The heaviside function is part of the Symbolic Math Toolbox. If you do not have this TB, you can write your own heaviside function
function y = heaviside(x)
y = (x > 0) + 0.5*(x == 0);
1 件のコメント
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!