0
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
1

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

Login to add comment


0

acos (Matlab work) — Inverse cosine

acosh (Matlab work) — Inverse hyperbolic cosine

acot (Matlab work) — Inverse cotangent

acoth (Matlab work) — Inverse hyperbolic cotangent

acsc (Matlab work) — Inverse cosecant

acsch (Matlab work) — Inverse hyperbolic cosecant

all (Matlab work) — Test to decide whether all components are nonzero

point (Matlab work) — Phase edge

any (Matlab work) — Test to decide whether any nonzeros components

An individual can likewise utilize his/her panseva card as a proof of character and verification of age. Being an officially sanctioned card, it is acknowledged as ID evidence for everything from purchasing a vehicle to applying for a credit.

Oops! Looks like spam! Waiting for moderator approval
31-12-18, 4:24 p.m. veerjahan

Login to add comment
Oops! Looks like spam! Waiting for moderator approval


Log-in to answer to this question.