他在answer和mtrw上的rzdwd评论说,要想精细化这里是最简洁的版本,我可以想到() 1的n变种为3,给出值0 iable vec )。
value=uint32(vec(1:16 )4.^ ) 0336015 );
这样,第一个组件数组结果的底部显式英寸将使用以下命令,将治疗的第一个元素作为最显式位
value=uint 32 (vec (16:-1:1 )4.^(0336015 ) );
编辑:为解决这个问题的新改版……。
如果向量元素的数量不是16的倍数,则提取的最后一组数量将少于16。 你可能想用零填充这个系列的高位,使之成为16元素的向量。 根据该系列的第一个元素是最不明显的位(LSB )或最明显的位(MSB ),最终填充该系列。
v=[2 3 1 1 3 1 2 2]; % a sample8-元素向量器
v=[ v zeros (1,8 ) ]; %ifv(1) is the LSB,set the higher bits to zero
% or .
v=[ zeros (1,8 ) v]; %ifv(1) is the MSB,again set the higher bits to zero
如果一口气处理整个向量,这里你怎么办(包括和所需的零补充),vec )1)是LSB :
nvalues=numel(vec;
nrem=rem(nvalues,16 );
VEC=[vec(3360 ) zeros(1) 1,nRem ) ] % Pad with zeroes
vec=reshape(vec,16,[] ); % reshape to an n-by-16矩阵
values=uint32(vec*4.^(0:15 ) );
vec(1)为MSB时:
nvalues=numel(vec;
nrem=rem(nvalues,16 );
vec=[vec(1: ) nvalues-nrem ] zeros (1,nrem ) ) ) ) ) ) ) )。
VEC(nvalues-nrem1 ) :nValues ); % Pad with zeroes
vec=reshape(vec,16,[] ); % reshape to an n-by-16矩阵
values=uint32(fliplr(vec )4.^ ) 0336015 );