简体   繁体   English

matlab - 如何形成矩阵的output

[英]matlab - how to form output of matrix

I have used the following commands我使用了以下命令

Arrival_A_PB_VS_PB_ID=[Arrival_A_PB_VS_PB_ID;[PB_ID,time]]; 
Arrival_A_PB_VS_PB_ID2 = vec2mat(Arrival_A_PB_VS_PB_ID,10,4);
Arrival_A_PB_VS_PB_ID2(Arrival_A_PB_VS_PB_ID2==0)=[];



       1        1610           2        1615           3        1620           4        1625           5        1630
       6        1635           7        1640           8        1645           9        1650          10        1655
      11        1660          12        1665          13        1670          14        1675          15        1680
      16        1685          17        1690          18        1695          19        1700          20        1705

this is the result i get, but is there anyway that i can get the results in an order:这是我得到的结果,但无论如何我可以按顺序得到结果:

1 1610    6 1635     11 1660
2 1615    7 1640      12 1665

and so on...?等等...? I mean somehow sorted我的意思是某种排序

A small detour via a 3d matrix helps.通过 3d 矩阵绕道而行。 The input after the first line is probably: Arrival_A_PB_VS_PB_ID=[[1:20].',[1610:5:1705].']第一行之后的输入大概是: Arrival_A_PB_VS_PB_ID=[[1:20].',[1610:5:1705].']

1) Reshape so that 1:5 can be found together in one row (regardless at which dimension) y=reshape(Arrival_A_PB_VS_PB_ID,5,4,2) 1) 重新整形,以便可以在一行中找到 1:5(无论在哪个维度) y=reshape(Arrival_A_PB_VS_PB_ID,5,4,2)

2) You want a 4x10 matrix. 2) 你想要一个 4x10 矩阵。 Reshape to the intended size and previously permute the data so everything ends up where it should.重塑到预期的大小并预先排列数据,以便一切都在它应该的地方结束。 z=reshape(permute(y,[2,3,1]),4,10)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM