矢量形式输出 [英] Output in Vector form

查看:89
本文介绍了矢量形式输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到如下重塑功能的输出

I am getting output of reshape function as follow

s1 =

11 
00 
10 
11 
01 
11 
10 
10 
10 
10 
10 
10 
10 
01 
10 
01

如何将s1转换为

[1 1 0 0 1 0 1 1 0 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 1 0 0 1] 

所以我可以提取位值 s1(1)将为1 s1(3)将为0 s1(5)将为1

so i can pick up bit values s1(1) will be 1 s1(3) will be 0 s1(5) will be 1

我已经尝试了整形和转置,但是没有选择正确的位值.感谢任何帮助.

I have tried it with reshape and transpose but not picking up correct bit values. Appreciate any help..

我正在使用以下代码进行以下操作

I am doing following operation with below code

将密文转换为字节,然后计算索引变量(称为p)&公式是MOD(字节数,3).我的密文长度为5个字节,因此索引变量(p)为2.我将始终具有基于0或1或2的索引可变值.的字节数

converting cipher text to bytes, then I am calculating index variable (called as p) & formula is MOD(No of Bytes,3).. I have ciphertext length as 5 bytes so Index Variable (p) is 2.. I will always have index varaible values as 0 or 1 or 2 which will be based on no. of Bytes

说的密文是11001011 01111010 10101010 10011001 01010101

Say ciphertext is 11001011 01111010 10101010 10011001 01010101

此数据为5个字节,其中inde变量为2

This data is five bytes there for inde variable is 2

11001011 01111010 10101010 10011001 01010101

11001011 01111010 10101010 10011001 01010101

现在 对于前两位(11),将索引变量分配为2 对于接下来的两位(00),将索引变量分配为0 对于接下来的两位(10),将索引变量分配为1 对于接下来的两位(11),将索引变量分配为2..so,直到我的位末尾.

Now for first two bits (11) , index variable to be assigned as 2 for next two bits (00), index variable to be assigned as 0 for next two bits (10), index variable to be assigned as 1 for next two bits (11), index variable to be assigned as 2..so on till end of my bits.

其他示例 具有三个字节的密码器11001011 01111010 10101010 索引变量(p)将为0

Other Example Ciphertet with Three Bytes 11001011 01111010 10101010 Index Variable (p) will be 0

对于前两位(11),将索引变量分配为0 对于接下来的两位(00),将索引变量分配为1 对于接下来的两位(10),将索引变量分配为2 对于接下来的两位(11),将索引变量分配为0. 等到我的一切结束..

for first two bits (11) , index variable to be assigned as 0 for next two bits (00), index variable to be assigned as 1 for next two bits (10), index variable to be assigned as 2 for next two bits (11), index variable to be assigned as 0.. so on till end of my bits..

s = '11001011 01111010 10101010 10011001 01010101'
p = rem(numel(regexp(s,' [01]'))+1,3)
k = (0:2)'
s1 = reshape(regexprep(s,' ',''),2,[])'
n = size(s1,1)
N = k(:,ones(fix((n+1)/3)+1,1))
P = N(find(N(:,1) == p)+(0:n-1))'

推荐答案

好吧s1'会给您

[11 00 10 11 ...]

但是,如果您向我们展示功能的输入,我也许可以为您提供真正想要的答案.

but if you show us the input to your function I might be able to give you the answer you really want.

这篇关于矢量形式输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆