重塑列向量 [英] Reshape column vector

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

问题描述

您好,我正在使用MATLAB,并且有一个尺寸为(9680 x 1)的"z" 列向量.我想重塑形状,以便具有尺寸为(44 x 220)的数组"z".我正在执行以下操作:

Hello I'm working with MATLAB and I have a "z" column vector that has dimension of (9680 x 1). I want to reshape it in order to have an array "z" of dimension (44 x 220). I'm doing the following:

z=reshape(z,44,220);

我也尝试过:

z=reshape(z,[44,220]);

但是输出不正确(至少第一行).通过将输出矩阵与初始向量进行比较,可以看到它.

But the output is not right (at least the first row). I can see it by comparing the output matrix with the initial vector.

我只需要将列向量的220个第一个位置作为矩阵的第一行的长度,然后将向量的下一个220个位置作为矩阵的第二行,依此类推,直到获得44行.

I just need the 220 first positions of the column vector to be the length of the first row of the matrix, then the next 220 positions of the vector to be the second row of the matrix and so on till obtaining 44 rows.

我做错了什么?感谢您的帮助.

What am I doing wrong? Thanks for your help.

推荐答案

Matlab以列主格式存储矩阵值(这在整形时很重要).由于您要专业,所以需要做

Matlab stores the matrix values in column major format (this is important during reshape). Since you want row major, you need to do

z = reshape(z, [220 44]).';

即然后转置.

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

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