Equivalent function for heaviside in scilab

Is there any equivalent function to 'heaviside' in Scilab?

in MATLAB `heaviside(x)` returns the value `0` for `x < 0`, `1` for `x > 0`, and `1/2` for `x = 0`.

is there any such function? if yes, how to use it?

Scilab 20-12-18, 10:03 p.m. Akhtar

Hello,

It could be easily done using following function (writtenn as a script with an example).

// ska109 - Jan (jenik) Skapa
// Department of Telecommunications
// Faculty of Electrical Engineering and Computer Science
// VSB - Technical University of Ostrava
// 17. listopadu 15/2172
// 708 33 Ostrava - Poruba
// Czech Republic
// Date: 21.12.2018
//
// Contact: ska109@vsb.cz

clear(); // Remove all variables
xdel(winsid()); // Close all graphic windows
clc; // Clear the Scilab Console

function y = heaviside(x)
[r, c] = size(x);
y = zeros(r, c);
y(x == 0) = 1/2;
y(x > 0) = 1;
endfunction

// Example
x = -10:10;
y = heaviside(x - 2); // Time-shift applied
plot2d3(x, y, color('red'));
xlabel('x'); title('y = heaviside(x - 2)');

25-12-18, 10:38 p.m. ska109
You can save the function heaviside.sci
`function y = heaviside(x)  [r, c] = size(x);  y = zeros(r, c);  y(x == 0) = 1/2;  y(x > 0) = 1;endfunction`
in some directory called "MyFunctions". If you are using the startup file, you can load all functions in this directory using
`getd('...PathTo/MyFunctions')`

27-12-18, 3:37 p.m. ska109
Thank You very much.

29-12-18, 11:15 a.m. Akhtar

The math problems are very difficult for me, hope to find good fake ways here. Entertainment with slope game you will find extremely interesting.
09-02-22, 3:05 p.m. sarahroxon