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

    %% Convert an Array to Fixed Point  

% Copyright 2015 The MathWorks, Inc.


%% 
% Define a 2-by-3 matrix of ones. 
A = ones(2,3);  

%% 
% Create a signed |fi| object with word length of |16| and fraction length
% of |8|. 
p = fi([],1,16,8);  

%% 
% Convert |A| to the same data type and complexity (real or complex) as |p|. 
B = cast(A,'like',p)