Matlab函数学习(2)
来源:互联网 发布:格式工厂有mac版吗 编辑:程序博客网 时间:2024/06/03 20:16
语法(Syntax)
B = reshape(A,m,n)
B = reshape(A,m,n,p……)
B = reshape(A,[m,n,p……])
B = reshape(A,……,[],……)
B = reshape(A,siz)
描述:
B= reshape(A,m,n) ——返回m*n的 矩阵B,其元素是列取自A,可能的错误结果:如果没有m * n个元素。(returns the m-by-n matrix B whose elements are taken column-wise from A. An error results if A does not have m*n elements.)
B = reshape(A,m,n,p,...) or B = reshape(A,[m n p ...])——返回一N-D飞数组元素,其大小为m*n*p。指定的B尺寸,m * n * p *必须与A有相同的大小(returns an N-D array with the same elements as A but reshaped to have the size m-by-n-by-p-by-... . The product of the specified dimensions, m*n*p*..., must be the same as prod(size(A)).
B = reshape(A,...,[],...) ——[]:计算的长度尺寸所代表的占位符,这样的B的尺寸等于A的后面的大小。calculates the length of the dimension represented by the placeholder [], such that the product of the dimensions equals prod(size(A)). The value of prod(size(A)) must be evenly divisible by the product of the specified dimensions. You can use only one occurence of [].
B = reshape(A,siz)——返回B的大小就是size。 returns an N-D array with the same elements as A, but reshaped to siz, a vector representing the dimensions of the reshaped array. The quantity prod(siz) must be the same as prod(size(A)).
Examples
转换成:将3*4的矩阵转换成2*6的矩阵。
A= 1 4 7 10
2 5 8 11
3 6 9 12
B=reshape(A,2,6)
B= 1 3 5 7 9 11
2 4 6 8 10 12
B=reshape(A,2,[])
B= 1 3 5 7 9 11
2 4 6 8 10 12
2.norm()
向量和矩阵的规范.
语法:
n =norm(X);
n =norm(X,p);
注意:norm(x)是一个矢量的欧氏长度x。p指开方次数,p=2;即开二次方求几何距离。
x = [0 1 2 3]
x =
0 1 2 3
sqrt(0+1+4+9) % Euclidean length
ans =
3.7417
norm(x)
ans =
3.7417
n = length(x) % Number of elements
n =
4
rms = 3.7417/2 % rms = norm(x)/sqrt(n)
rms =
1.8708
距离:
X=[-2,3,-1]
n=norm(x);
n=
3.7417
n=norm(X,1)
n=6
- Matlab函数学习(2)
- Matlab:plot函数学习(2)
- Matlab函数学习(1)
- Matlab函数学习(3)
- MATLAB学习(五)MATLAB中调用C语言函数
- Matlab画函数图学习笔记2
- MATLAB学习笔记(1 )find函数
- Matlab:plot函数学习(1)
- MATLAB学习笔记 函数记录(一)
- MATLAB学习笔记 函数记录(二)
- MATLAB学习笔记 函数记录(三)
- MATLAB学习笔记 函数记录(四)
- Matlab学习笔记(一)基础函数
- MATLAB 函数学习笔记
- Matlab学习记录(函数)
- 机器学习MATLAB函数
- MATLAB学习之函数
- 【Matlab学习笔记】【函数学习】一(延时函数pause)
- Google Play In-app Billing 踩过的那些坑
- ContentProvider源码分析
- find命令的几个例子解析(-a,-o,-path,-wholename,-prnue,-print)
- 面向对象三大特性-封装、继承、多态
- Android系统联系人全特效实现(上),分组导航和挤压动画
- Matlab函数学习(2)
- LINUX编程——进程间管道通信
- 如何在编程中确保服务器的性能
- Linux编程——ls命令的实现
- 最大流
- Swift and Objective-C in the Same Project
- Android系统联系人全特效实现(下),字母表快速滚动
- 【SzNOI语法百题】【d025】从 n 个数中挑选出最大的数
- JSP页面报错:org.apache.jasper.JasperException