%--------------------------------------------------------------------------
%   [dataout] = d2h(datain,N_bit)
%--------------------------------------------------------------------------
%   功能:
%   转换10进制数到16进制模式(常用于FPGA测试中)
%--------------------------------------------------------------------------
%   input:
%           datain                  输入数据
%           N_bit                   转换位数
%   output:
%           dataout                 输出数据
%--------------------------------------------------------------------------
%   Examples:   
%   d2h(13,5)
%   ans = 
%       "D"
%   d2b(-13,5)
%   ans = 
%       "10011"
%--------------------------------------------------------------------------
function dataout = d2h(datain,N_bit)
[X,Y,Z] = size(datain);
datain(datain<0) = datain(datain<0)+2^N_bit;
h = dec2hex(datain);
temp = string([]);
for index = 1:X*Y*Z
    temp(index)= string(h(index,:));
end
dataout = reshape(temp,[X Y Z]);
end


    
    