【matlab】利用sortrows进行Z字形扫描

本文介绍了如何在MATLAB中利用sortrows函数进行Z字形扫描,详细阐述了sortrows的基本语法,包括按升序排序矩阵的行以及基于指定列进行多列排序的方法。同时,也提及了reshape函数的使用,用于矩阵的重塑,通过sz1,...,szN参数重新定义矩阵的尺寸,以适应不同场景的需求。" 112942271,10538603,Python连接Oracle数据库实战指南,"['Python开发', '数据库连接', 'Oracle数据库', 'Linux系统', 'Windows系统']

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  • Syntax of sortrows

B = sortrows(A) sorts the rows of A in ascending order. For strings, this is the familiar dictionary sort.

B = sortrows(A,column) sorts matrix A based on the columns specified in the vector, column. This input is used to perform multiple column sorts in succession.

[B,index] = sortrows(_) also returns an index vector using any of the previous syntaxes. The index vector satisfies B = A(index,:).

  • Systax of reshape

B = reshape(A,sz1,…,szN) reshapes A into a sz1-by-…-by-szN array where sz1,…,szN indicates the size of each dimension. You can specify a single dimension size of [] to have the dimension size automatically calculated, such that the number of elements in B matches the number of elements in A. For example, if A is a 10-by-10 matrix, then reshape(A,2,2,[]) reshapes the 100 elements of A into a 2-by-2-by-25 array.

>> order = [ 0  1  5  6  14 15 27 28
             2  4  7  13 16 26 29 42
             3  8  12 17 25 30 41 43
             9  11 18 24 31 40 44 53
             10 19 23 32 39 45 52 54
             20 22 33 38 46 51 55 60
             21 34 37 47 50 56 59 61
             35 36 48 49 57 58 62 63];
>>  q =  [16 11 10 16 24  40  51  61 
          12 12 14 19 26  58  60  55
          14 13 16 24 40  57  69  56
          14 17 22 29 51  87  80  62
          18 22 37 56 68  109 103 77
          24 35 55 64 81  104 113 92
          49 64 78 87 103 121 120 101
          72 92 95 98 112 100 103 99];
>>  C = sortrows([reshape(q,[],1) reshape(order,[],1)],2)

>> C(:,1)'
ans =

  12116    11    12    14    12    10    16    14    13    14    18    17    16    19    24    40    26    24    22    22    24

  224249    35    37    29    40    58    51    61    60    57    51    56    55    64    72    92    78    64    68    87    69

  436355    56    80   109    81    87    95    98   103   104   103    62    77   113   121   112   100   120    92   101   103

  6499
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值