linedir.m

来自「经典通信系统仿真书籍《通信系统与 MATLAB (Proakis)》源代码」· M 代码 · 共 28 行

M
28
字号
function direct = linedir(layout);
%LINEDIR finds the direction of a line segment
%	layout = [x1,y1; x2.y2;...]
%	direct = 0>, 1v, 2<, 3^ 
%       direct = -1 if it is not a straight line
%

%	Copyright (c) 1990-94 by The MathWorks, Inc.

if layout(1, 2) == layout(2, 2)
   %horizontal
   if layout(1, 1) < layout(2, 1)
      direct = 0;
   else
      direct = 2;
   end;
elseif layout(1, 1) == layout(2, 1)
   %verticle
   if layout(1, 2) < layout(2, 2)
      direct = 1;
   else
      direct = 3;
   end;
else
   % in the case of not a straight line
   direct = -1;
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?