direction.m
来自「Cordic算法的Matlab实现」· M 代码 · 共 28 行
M
28 行
%% description
% In order to find the right direction to rotate, this
% program was provided.According to the algorithm, it's
% much too easy to choose di. However, this file was
% provided separately to make the structure of the
% program clear.
% inputs/outputs refer to cordic.m,while dv_name denotes
% the name of the decision variable
%% code
function di=direction(dv,dv_name)
% check the No. of inputs
if(nargin<2)
dv_name='z'; % default decision variable:z
end
% main code section
di=1;
if(dv_name=='x' || dv_name=='y' || dv_name=='z')
% main code section
if(dv_name=='z') % z is decision variable
if(dv<0) di=-1; end
else % x/y is decision variable
if(dv>=0) di=-1; end
end
else printf('Wrong decision name!\n');
end
%end of function
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?