【问题标题】:How two reshape two columns into multiple columns in matlab如何在matlab中将两列重塑为多列
【发布时间】:2014-03-24 23:10:22
【问题描述】:

有谁知道我可以如何重塑这两列:

     1     1
     1     1
     1     1
   379   346
   352   363
   330   371
   309   379
   291   391
   271   402
   268   403
     1     1
     1     1
   406   318
   379   334
   351   351
   329   359
   307   367
   287   378
   267   390
   264   391

分为这四列:

     1     1    1      1
     1     1    1      1
     1     1    406  318  
   379   346    379  304 
   352   363    351  351 
   330   371    329  359 
   309   379    307  367
   291   391    287  378
   271   402    267  390
   268   403    264  391

即matlab中如何将Nx2大小的矩阵reshape成10xM大小的矩阵?

【问题讨论】:

    标签: matlab matrix multiple-columns reshape


    【解决方案1】:

    使用 mat2cell 的一种解决方案,每 10 行拆分一次。可能更容易理解,因为没有使用 3d 矩阵:

    cell2mat(mat2cell(x,repmat(10,size(x,1)/10,1),size(x,2))')
    

    使用重塑和置换的第二种解决方案,应该更快,但我没有尝试过。:

    reshape(permute(reshape(x,10,[],size(x,2)),[1,3,2]),10,[])
    

    【讨论】:

      猜你喜欢
      • 2017-05-05
      • 1970-01-01
      • 2021-11-26
      • 1970-01-01
      • 2022-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-30
      相关资源
      最近更新 更多