deg180.m

来自「JLAB is a set of Matlab functions I have」· M 代码 · 共 42 行

M
42
字号
function[varargout]=deg180(varargin)%DEG180  Converts degrees from the range [0,360] to [-180,180].%%   [TH1,TH2,...THN]=DEG180(TH1,TH2,...THN) converts the range of the%   input angles, which are measured in degrees, to [-180, 180].%%   See also DEG360.%%   'deg180 --t' runs a test.%   __________________________________________________________________%   This is part of JLAB --- type 'help jlab' for more information%   (C) 2006 J.M. Lilly --- type 'help jlab_license' for details if strcmp(varargin{1}, '--t')    deg180_test,returnend varargout=varargin;for i=1:nargin;    th=varargin{i};    index=find(isfinite(th));    if ~isempty(index)        if minmin(th(index))<-180 || maxmax(th(index))>360            error(['Range of TH' int2str(i) ' lies outside [-180,360]'])        end    else        error(['Range of TH' int2str(i) ' lies outside [-180,360]'])    end        index=find(th>180);    if ~isempty(index)        th(index)=th(index)-360;    end    varargout{i}=th;endfunction[]=deg180_testthi=[359 181];tho=[-1 -179];reporttest('DEG180 simple',aresame(deg180(thi),tho))

⌨️ 快捷键说明

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