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

    %% Calculate the CORDIC Square Root
% 
%%
% Find the square root of |fi| object |x| using a CORDIC implementation.

% Copyright 2015 The MathWorks, Inc.

x = fi(1.6,1,12);
y = cordicsqrt(x)
%%
% Because you did not specify |niters|, the function performs the maximum
% number of iterations, |x.WordLength - 1|.
%%
% Compute the difference between the results of the |cordicsqrt| function and
% the double-precision |sqrt| function.
err = abs(sqrt(double(x))-double(y))
%%