www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/FindSignFunctionExample.m

    %% Find Sign Function
% Find the sign function of a number.

% Copyright 2015 The MathWorks, Inc.

sign(2)
%%
% Find the sign function of the values of a vector.
V = [-11 0 1.5 Inf NaN];
sign(V)
%% 
% Find the sign function of the values of a matrix.
M = magic(3) - 5;
sign(M)
%% 
% Find the sign function of a complex number.
z = 4 - 3*i;
sign(z)