简体   繁体   English

在原点更改Heaviside功能

[英]Changing the Heaviside function at origin

is there any way to change the value of heaviside function at zero in matlab 2014b? 在Matlab 2014b中,有什么方法可以将heaviside函数的值更改为零? because I have to change the value from 0.5 to 1. 因为我必须将值从0.5更改为1。

You can use the 'HeavisideAtOrigin' preference of sympref to set a custom value at the origin: 您可以使用sympref'HeavisideAtOrigin'首选项在sympref设置自定义值:

sympref('HeavisideAtOrigin',1);
one = heaviside(-1:1)
sympref('HeavisideAtOrigin',0.5);
pointFive= heaviside(-1:1)

...

one =

     0     1     1


pointFive =

         0    0.5000    1.0000

The above was introduced in R2015a . 以上内容是在R2015a介绍的 For pre-R2015a, you'll have to build your own fix for this, eg: 对于R2015a之前的版本,您必须为此构建自己的修复程序,例如:

% heavisideOrigin1.m
function y = heavisideOrigin1(x)
    y = round(heaviside(x));
end

% ...
y = heavisideOrigin1(-1:1)

% prints
y =

     0     1     1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM