Example11(June 9,2015)
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 %--------------sort------------------------------- 2 >> A=[9 3;8 2;1 5] 3 A = 4 5 9 3 6 8 2 7 1 5 8 >> B=sort(A,2)%A(:,1)<=A(:,2) 9 B = 10 3 9 11 2 8 12 1 5 13 %---------------END----------------------------------- 14 %--------------reshape------------------------------- 15 >> j=1:6; 16 >> NT=2; 17 >> A=reshape(j,NT,3)或者A=reshape(j',NT,3) 18 %讲一个行(列)向量转化为一个指定规模的矩阵(NT*3) 19 A = 20 1 3 5 21 2 4 6 22 %---------------END----------------------------------- 23 %--------------unique--------------------------------- 24 >> node=[0 0;1 0;1 1;0 1]; 25 >> elem=[1 2 4;2 3 4]; 26 >> totalEdge=sort([elem(:,[2,3]);elem(:,[3,1]);elem(:,[1,2])],2); 27 >> totalEdge=sort([elem(:,[2,3]);elem(:,[3,1]);elem(:,[1,2])],2) 28 totalEdge = 29 2 4 30 3 4 31 1 4 32 2 4 33 1 2 34 2 3 35 >> [edge,i2,j]=unique(totalEdge,'rows') 36 edge = %去掉totalEdge中重复的边,edge(:,1)由小到大向下排 37 1 2 38 1 4 39 2 3 40 2 4 41 3 4 42 i2 = 43 5 44 3 45 6 46 4 47 2 48 j = 49 4 50 5 51 2 52 4 53 1 54 3 55 %--------------END------------------------------------