2010-05-19 50 views
0

我想找到一種在MATLAB中繪製桁架的方法,我可以通過使用鄰接矩陣和gplot函數來實現,但是它非常冗長的方法,特別是在連接了很多節點的情況下彼此。有沒有更快的方法來做到這一點?MATLAB和gplot

回答

0

我認爲gplot是繪製桁架的好函數。但是,可以簡化鄰接矩陣的創建。

例如,如果你的coordinates存儲在n乘2陣列,並且對於每對節點的由小於dMax分離的支柱,可以創建鄰接矩陣是這樣的:

%# create a distance matrix 
distMatSquared = coordinates * coordinates'; %' #SO formatting 

%# create an adjacency matrix that has a 1 wherever 
%# distMatSquared is smaller than dMax^2, and that has 0 everywhere else 
adjacencyMatrix = distMatSquared < dMax^2; 

%# plot the truss with circles at the nodes 
figure,gplot(adjacencyMatrix,coordinates,'-o'); 
+0

這個問題,我需要對你的想法有一個小小的混亂,讓它爲我的桁架工作,但是你需要答覆。 – JPC 2010-05-20 10:18:30