simple jump function in matlab

Here is an example of a simple jump function in MATLAB:

main.m
function y = jump(x)
if x >= 0
    y = x + 1;
else
    y = x - 1;
end
end
74 chars
8 lines

This function takes an input x, and outputs x+1 if x is non-negative, and x-1 otherwise. The if statement in the middle is the conditional that performs the "jump".

related categories

gistlibby LogSnag