开发者

MATLAB and gplot

开发者 https://www.devze.com 2022-12-31 21:29 出处:网络
I\'m trying to find a way to plot a truss in MATLAB, I can do it by using an adjacency matrix and the gplot function, but its very long winded approach especially if there are a lot of nodes connected

I'm trying to find a way to plot a truss in MATLAB, I can do it by using an adjacency matrix and the gplot function, but its very long winded approach especially if there are a lot of nodes connected to one another. Is there a fas开发者_JAVA技巧ter way to do this?


I think gplot is a good function to plot a truss. However, it might be possible to simplify the creation of the adjacency matrix.

For example, if your coordinates are stored in a n-by-2 array, and there is a strut for every pair of nodes that is separated by less than dMax, you can create the adjacency matrix like this:

%# 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');


If this is a truss in the Mechanics of Materials sense:

http://www.mathworks.com/matlabcentral/fileexchange/2170-mastering-mechanics-1-using-matlab-5

and the supporting book

http://www.amazon.com/Mastering-Mechanics-Using-MATLAB-Materials/dp/0138640343

I wrote some truss visualization and just general strength of material stuff into this.

0

精彩评论

暂无评论...
验证码 换一张
取 消