📄 mbyteunpack.m
字号:
function [output] = mByteUnpack(input)
% Auxiliary function to unpack bytes into bits
%
% output = mByteUnpack(input)
%
% input : input vector/matrix (bytes, values 0 to 255)
% output: output vector/matrix (bits, values 0 or 1)
%
% The size of the output is eight times the size of the input.
%
% If the input is a matrix, columns are treated as a vector, i.e. the
% data is unpacked column by column.
%
% See also mBytePack
%
% Matlab 7 Release 14 SP2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Property of Freescale
% Freescale Confidential Proprietary
% Freescale Copyright (C) 2005 All rights reserved
% ----------------------------------------------------------------------------
% $RCSfile: mByteUnpack.m.rca $
% $Revision: 1.1 $
% $Date: Mon Dec 11 15:21:52 2006 $
% Target: Matlab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Written by: Karsten Mohr
% Date: 06-Aug-2005
%check input dimension
if ndims(input)~=2
error('Error: Input must be a vector or 2-dim matrix.');
end
%get input size
[m,n]=size(input);
x=m*8; y=n; %output dimension
if m==1
%make col vector from row vector
input=input';
m=n; n=1;
x=1; y=m*8; %output dimension
end
output = logical(zeros(m*8,n));
for k=1:n,
temp1 = double(input(:,k))*ones(1,8);
temp2 = ones(m,1)*[128 64 32 16 8 4 2 1];
output(:,k) = reshape(sign(bitand(temp1,temp2))',m*8,1);
end
output=reshape(output,x,y);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -