deg360.m

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

M
50
字号
function[varargout]=deg360(varargin)%DEG360  Converts degrees from the range [-180,180] to [0,360].%%   [TH1,TH2,...THN]=DEG360(TH1,TH2,...THN) converts the range of the%   input angles, which are measured in degrees, to [0, 360].%%   See also DEG180.%%   'deg360 --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')    deg360_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<0);    if ~isempty(index)        th(index)=th(index)+360;    end    varargout{i}=th;endfunction[]=deg360_testthi=[-1 -179];tho=[359 181];reporttest('DEG360 simple',aresame(deg360(thi),tho))th1=360*rand(100,1);th2=deg360(deg180(th1));reporttest('DEG360 inverts DEG180',aresame(th1,th2)) %reporttest(' DEG360 ',aresame())

⌨️ 快捷键说明

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