reshape把指定的矩阵改变形状,但是元素个数不变,

例如,行向量:

a = [1 2 3 4 5 6]

执行下面语句把它变成3行2列:

b = reshape(a,3,2)

执行结果:

b =

1 4

2 5

3 6

若a=[1 2 3

4 5 6

7 8 9]

可以从b中看到reshape是按列来读取的,如

a=[1  2 ; 3  4]

如果使用b=reshape(a,1,4)

则得到的结果是

b=[1 3 2 4]

如果想得到

b=[1 2 3 4]

需要使用

b=reshape(a',1,4)

因为reshape使用的列优先!

b转化回去是同样的道理。

 

使用reshpe后想得到b=[1 2 3 4 5 6 7 8 9]

只需要将a转置一下就可以了:

b=reshape(a',1,9)

----------------------------------------------

matlab中的解释如下:

RESHAPE Change size.

    RESHAPE(X,M,N) returns the M-by-N matrix whose elements

    are taken columnwise from X. An error results if X does

    not have M*N elements.

 

    RESHAPE(X,M,N,P,...) returns an N-D array with the same

    elements as X but reshaped to have the size M-by-N-by-P-by-...

    M*N*P*... must be the same as PROD(SIZE(X)).

 

    RESHAPE(X,[M N P ...]) is the same thing.

 

    RESHAPE(X,...,[],...) calculates the length of the dimension

    represented by [], such that the product of the dimensions

    equals PROD(SIZE(X)). PROD(SIZE(X)) must be evenly divisible

    by the product of the known dimensions. You can use only one

    occurrence of [].

 

    In general, RESHAPE(X,SIZ) returns an N-D array with the same

    elements as X but reshaped to the size SIZ. PROD(SIZ) must be

    the same as PROD(SIZE(X)).

 

源文档 <http://blog.sina.com.cn/s/blog_5feb3cea0100lz8b.html>

Matlab中reshape函数的使用的更多相关文章

  1. matlab中patch函数的用法

    http://blog.sina.com.cn/s/blog_707b64550100z1nz.html matlab中patch函数的用法——emily (2011-11-18 17:20:33) ...

  2. matlab中subplot函数的功能

    转载自http://wenku.baidu.com/link?url=UkbSbQd3cxpT7sFrDw7_BO8zJDCUvPKrmsrbITk-7n7fP8g0Vhvq3QTC0DrwwrXfa ...

  3. 【原创】Matlab中plot函数全功能解析

    [原创]Matlab中plot函数全功能解析 该帖由Matlab技术论(http://www.matlabsky.com)坛原创,更多精彩内容参见http://www.matlabsky.com 功能 ...

  4. matlab 中max函数用法

    Matlab中max函数在矩阵中求函数大小的实例如下:(1)C = max(A)返回一个数组各不同维中的最大元素.如果A是一个向量,max(A)返回A中的最大元素.如果A是一个矩阵,max(A)将A的 ...

  5. Matlab中plot函数全功能解析

    Matlab中plot函数全功能解析 功能 二维曲线绘图 语法 plot(Y)plot(X1,Y1,...)plot(X1,Y1,LineSpec,...)plot(...,'PropertyName ...

  6. matlab中cumsum函数

    matlab中cumsum函数通常用于计算一个数组各行的累加值.在matlab的命令窗口中输入doc cumsum或者help cumsum即可获得该函数的帮助信息. 格式一:B = cumsum(A ...

  7. 『转载』Matlab中fmincon函数获取乘子

    Matlab中fmincon函数获取乘子 一.输出结构 [x,fval,exitflag,output,lambda] = fmincon(......) 二.结构说明 lambda结构 说     ...

  8. matlab中norm函数的用法

    格式:n=norm(A,p) 功能:norm函数可计算几种不同类型的矩阵范数,根据p的不同可得到不同的范数 以下是Matlab中help norm 的解释 NORM   Matrix or vecto ...

  9. matlab中fprintf函数的具体使用方法

    matlab中fprintf函数的具体使用方法实例如下: fprintf函数可以将数据按指定格式写入到文本文件中.其调用格式为: 数据的格式化输出:fprintf(fid, format, varia ...

随机推荐

  1. GET/POST请求的使用《极客学院 --AFNetworking 2.x 网络解析详解--2》学习笔记

    AFNetworking是开源代码排名第一的开源库.  GET请求的请求正文 一般都是明文显示的,携带的数据量小. POST用于处理复杂的业务,并不用明文的请求,其实POST请求可以携带更多的参数,只 ...

  2. Effective Java 01 Consider static factory methods instead of constructors

    Advantage Unlike constructors, they have names. (BigInteger.probablePrime vs BigInteger(int, int, Ra ...

  3. Effective Java 74 Implement Serializable judiciously

    Disadvantage of Serializable A major cost of implementing Serializable is that it decreases the flex ...

  4. Spring依赖注入三种方式详解

    在讲解Spring依赖注入之前的准备工作: 下载包含Spring的工具jar包的压缩包 解压缩下载下来的Spring压缩包文件 解压缩之后我们会看到libs文件夹下有许多jar包,而我们只需要其中的c ...

  5. 烂泥:SQL Server 2005数据库备份与恢复

    本文由秀依林枫提供友情赞助,首发于烂泥行天下. 服务器的迁移,因为业务使用的数据库是SQL Server 2005,所以就要首先对数据库进行备份. 备份可以分为手动备份和自动备份,我们先来介绍手动备份 ...

  6. Linux 学习之DNS服务器

    概念: DNS:Domain Name System 域名系统 FQDN:Fully Qualified Domain Name 完整主机名 正向解析:由主机名查IP地址 SOA:开始验证(Start ...

  7. Android中的Shape使用总结

    参考:http://www.cnblogs.com/gzggyy/archive/2013/05/17/3083218.html 在Android程序开发中,我们经常会去用到Shape这个东西去定义各 ...

  8. [转]Google Cloud Messaging: Overview

    本文转自:https://developers.google.com/cloud-messaging/gcm

  9. 【转】C语言位运算符:与、或、异或、取反、左移与右移详细介绍

    转载自:http://www.jb51.net/article/40559.htm,感谢原作者. 以下是对C语言中的位运算符:与.或.异或.取反.左移与右移进行了详细的分析介绍,需要的朋友可以过来参考 ...

  10. codeforces 577B B. Modulo Sum(水题)

    题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...