matlab大小以及结构改变

发布时间:2025-12-10 11:41:54 浏览次数:3

函数名称函数功能
fliplr(A)矩阵每一行均进行逆序排列
flipud(A)矩阵每一列均进行逆序排列
flipdim(A, dim)生成一个在 dim 维矩阵 A 内的元素交换位置的多维矩阵
rot90(A)生成一个由矩阵 A 逆时针旋转 90°而得到的新矩阵
rot90(A, k)生成一个由矩阵 A 逆时针旋转 kx90°而得到的新矩阵
reshape(A , m , n)生成一个 m x n 维的矩阵,其元素以线性索引的顺序从矩阵 A 中取得如果矩阵 A 中没有 mxnx 个元素,将返回一条错误信息
repmat(A,[m n···p])创建一个和矩阵 A 有相同元素的 mxnx···xp 块的多维矩阵
shiftdim(A , n)矩阵的列移动n 步。n 为正数,矩阵向左移;n 为负数,矩阵向右移
squeeze(A)返回没有空维的矩阵 A
cat( dim,A, B)将矩阵 A和 B 组合成一个 dim 维的多维矩阵
permute(A, order)根据向量 order 来改变矩阵 A 中的维数顺序
ipermute(A. order)进行命令 permute 的逆变换
sort(A)对一维或二维矩阵进行升序排序,并返回排序后的矩阵当 A 为二维矩阵时,对知阵的每一列分别进行排序
sort( A. dim)对矩阵按指定的方向进行升序排序,并返回排序后的矩阵。当 dim=1 时,对矩阵的每一列排序:当 dim=2 时,对知阵的每一行排序
sort(A, dim, mode)当 mode 为’ascend时,进行升序排序;当 mode 为descend时,进行降序排序
[B,IX] = sort(A…·.)IX 为排序后备元素在原矩阵中的行位置或列位置的索引

fliplr

>> a=[1 2 3;4 5 6;7 8 9]a =1 2 34 5 67 8 9>> fliplr(a)ans =3 2 16 5 49 8 7

flipud

>> flipud(a)ans =7 8 94 5 61 2 3

flipdim

>> flipdim(a,2)ans =3 2 16 5 49 8 7>> flipdim(a,3)ans =1 2 34 5 67 8 9>> flipdim(a,1)ans =7 8 94 5 61 2 3

rot90

>> rot90(a)ans =3 6 92 5 81 4 7>> rot90(a,2)ans =9 8 76 5 43 2 1

reshape

>> reshape(a,3,2)错误使用 reshape元素数不能更改。请使用 [] 作为大小输入之一,以自动计算该维度的适当大小。>> reshape(a,3,3)ans =1 2 34 5 67 8 9

repmat

>> repmat(a,[2,2,2])ans(:,:,1) =1 2 3 1 2 34 5 6 4 5 67 8 9 7 8 91 2 3 1 2 34 5 6 4 5 67 8 9 7 8 9ans(:,:,2) =1 2 3 1 2 34 5 6 4 5 67 8 9 7 8 91 2 3 1 2 34 5 6 4 5 67 8 9 7 8 9

shiftdim

>> shiftdim(a,1)ans =1 4 72 5 83 6 9>> shiftdim(a,-1)ans(:,:,1) =1 4 7ans(:,:,2) =2 5 8ans(:,:,3) =3 6 9

cat

>> cat(2,a,b)ans =1 2 3 1 0 14 5 6 2 2 07 8 9 0 0 0>> cat(3,a,b)ans(:,:,1) =1 2 34 5 67 8 9ans(:,:,2) =1 0 12 2 00 0 0>> cat(1,a,b)ans =1 2 34 5 67 8 91 0 12 2 00 0 0>> cat(4,a,b)ans(:,:,1,1) =1 2 34 5 67 8 9ans(:,:,1,2) =1 0 12 2 00 0 0

sort

>> sort([2 3 4 1 0 9 8 6])ans =0 1 2 3 4 6 8 9>> x=rot90(a,2)x =9 8 76 5 43 2 1>> sort(x,1)ans =3 2 16 5 49 8 7>> sort(x,2)ans =7 8 94 5 61 2 3>> sort(x,1,'ascend')ans =3 2 16 5 49 8 7>> sort(x,1,'descend')ans =9 8 76 5 43 2 1>> sort(x,2,'descend')ans =9 8 76 5 43 2 1>> sort(x,2,'ascend')ans =7 8 94 5 61 2 3
需要做网站?需要网络推广?欢迎咨询客户经理 13272073477