Matlab中reshape函数的使用
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函数的使用的更多相关文章
- matlab中patch函数的用法
http://blog.sina.com.cn/s/blog_707b64550100z1nz.html matlab中patch函数的用法——emily (2011-11-18 17:20:33) ...
- matlab中subplot函数的功能
转载自http://wenku.baidu.com/link?url=UkbSbQd3cxpT7sFrDw7_BO8zJDCUvPKrmsrbITk-7n7fP8g0Vhvq3QTC0DrwwrXfa ...
- 【原创】Matlab中plot函数全功能解析
[原创]Matlab中plot函数全功能解析 该帖由Matlab技术论(http://www.matlabsky.com)坛原创,更多精彩内容参见http://www.matlabsky.com 功能 ...
- matlab 中max函数用法
Matlab中max函数在矩阵中求函数大小的实例如下:(1)C = max(A)返回一个数组各不同维中的最大元素.如果A是一个向量,max(A)返回A中的最大元素.如果A是一个矩阵,max(A)将A的 ...
- Matlab中plot函数全功能解析
Matlab中plot函数全功能解析 功能 二维曲线绘图 语法 plot(Y)plot(X1,Y1,...)plot(X1,Y1,LineSpec,...)plot(...,'PropertyName ...
- matlab中cumsum函数
matlab中cumsum函数通常用于计算一个数组各行的累加值.在matlab的命令窗口中输入doc cumsum或者help cumsum即可获得该函数的帮助信息. 格式一:B = cumsum(A ...
- 『转载』Matlab中fmincon函数获取乘子
Matlab中fmincon函数获取乘子 一.输出结构 [x,fval,exitflag,output,lambda] = fmincon(......) 二.结构说明 lambda结构 说 ...
- matlab中norm函数的用法
格式:n=norm(A,p) 功能:norm函数可计算几种不同类型的矩阵范数,根据p的不同可得到不同的范数 以下是Matlab中help norm 的解释 NORM Matrix or vecto ...
- matlab中fprintf函数的具体使用方法
matlab中fprintf函数的具体使用方法实例如下: fprintf函数可以将数据按指定格式写入到文本文件中.其调用格式为: 数据的格式化输出:fprintf(fid, format, varia ...
随机推荐
- UIWebView的基本用法
一.UIWebView的基础使用 1.创建UIWebView: CGRect bouds = [[UIScreen manScreen]applicationFrame]; UIWebView* we ...
- svn错误
在myEclipse客户端第一次连到SVN时,如:svn://192.168.20.242/MyProject1,然后要求输入用户名和密码.如果用户名和密码输入出错了,强行确定后.问题来了!会出现,以 ...
- 配置gitlab gerrit jenkins
配置gerrit 在gerrit创建jenkins用户 把jenkins用户加入Non-Interactive的组中 Projects -> List -> All-Projects Pr ...
- jQuery Form 表单提交插件-----formSerialize,fieldSerialize,fieldValue,resetForm,clearForm,clearFields的 应用
一.jQuery Form的其他api 1. formSerialize 将表单序列化成查询串.这个方法将返回一个形如: name1=value1&name2=value2的字符串.是否可 ...
- 基于注解配置的Spring MVC 简单的HelloWorld实例应用
2.1 问题 使用注解的方式重构helloworld应用案例. 2.2 方案 1. @RequestMapping注解应用 @RequestMapping可以用在类定义和方法定义上,它标明这个类或方法 ...
- 【VB超简单入门】三、开始编程
接下来要进入正题了!同学们要认真看咯~ 第一步:安装VB开发IDE 在这里我推荐大家安装的是VB迷你版,现在大多数同学使用win7,这个版本可以在win7上运行的妥妥的~ 下载链接:http://pa ...
- CentOS下SSH无密码登录的配置
1.确认本机sshd的配置文件(需要root权限) $ gedit /etc/ssh/sshd_config 找到以下内容,并去掉注释符"#" RSAAuthentication ...
- Windows Live Writer离线编写博客
WLW最新版本为2012,官网下载 Windows Live Writer配置步骤 使用Windows Live Writer 2012和Office Word 2013 发布文章到博客园全面总结 L ...
- 由fdopen和fopen想到的
ISO C并没有规定fdopen,而是POSIX的补充. FILE *fopen(const char *path, const char *mode); FILE *fdopen(int fd, c ...
- seq 显示00 01的格式
for i in `seq -w 00 20` ; do echo $i ;done 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 ...