在MATLAB中重塑数组 [英] Reshaping of Array in MATLAB

查看:127
本文介绍了在MATLAB中重塑数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个32768 * 8的数组,我想将其转换为1 * 262144的数组.我使用过MATLAB命令重塑,但问题是重塑会按行更改矩阵,然后将其追加到列中.我也用过(V :);功能,但它也与重塑功能相同,因此没有用.

I have a 32768*8 array which I want to convert into a 1*262144 array. I have used the MATLAB command reshape but the problem is reshape changes the matrix row-wise and then appends it to the columns. I have also used the (V:); function but it also does the same as reshape so no use.

我希望保持二进制数据的完整性.所以 0F 4B = 0000 1111 0100 1011 ... etc应该像这样,而不是通过reshape命令来完成.

I want that the binary data integrity is maintained. So 0F 4B = 0000 1111 0100 1011...etc should be like this and not otherwise as done by the reshape command.

有什么想法吗? 谢谢!

Any ideas? Thanks!

推荐答案

您还可以先转置矩阵,然后再调用(:)命令!如果要使其成为行向量,请确保将向量转回.

You could also transpose your matrix first then invoke the (:) command too! Make sure you transpose your vector back if you want it to be a row vector.

MyMatrix = MyMatrix.';
MyVector = (MyMatrix(:)).';

在语法上也是正确的(由Dan启发-见下文),我还使用了.',因为使用'会调用复杂转置.它不仅可以转置向量,还可以共轭您的元素.如果要计算复数矢量的大小,这实际上非常有用,因为大小平方的定义是(a + ib)*(a - ib).如果我没记错的话,洛伦·舒尔(Loren Shure)的一篇文章(我不记得是哪篇)提到将复杂的转置放置在MATLAB中就是出于这个目的.

Also to be syntactically correct (inspired by Dan - see below), I have also employed .' as using ' will invoke the complex transpose. Not only will it transpose your vector, it will also conjugate your elements as well. This is actually quite useful if you want to calculate the magnitude of a complex vector, as the definition of the magnitude squared is (a + ib)*(a - ib). If I remember correctly, an article by Loren Shure (I can't remember which one) mentioned that the complex transpose was placed in MATLAB for this very purpose.

但是,如果所有元素都是真实的,则可以使用'.'.没关系.

However, if all of your elements are real, then you can either use ' or .'. Doesn't matter which one.

这篇关于在MATLAB中重塑数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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