필터 지우기
필터 지우기

How to plot frame structure with varying thickness?

조회 수: 6 (최근 30일)
Naresh Koju
Naresh Koju 2023년 4월 20일
댓글: Naresh Koju 2023년 6월 12일
I am using the Plot Frame Structure file from this link: https://www.mathworks.com/matlabcentral/fileexchange/74083-plot-frame-structure
and utilizing it to plot lattice structures. I am trying to plot the structures with varying element thickness such that the element thickness can be visualized (say if there are total of 8 elements in a frame. 5 of them are 1mm thick, 2 of them are 1.5mm thick and last one is 2mm thick. When plotting the frame, I want to create the structure with elements thickness proportional to these thickness value). Additionally, it will be good to have these thicker elements (1.5mm, 2mm in the example) represented with different color as well than baseline thickness size (1mm in example). I do have node coordinate matrix, element connectivity matrix and a column vector of each element thickness which correspondes to the element connectivity matrix.
Any help is higly appreciated.Thanks

채택된 답변

Saffan
Saffan 2023년 6월 1일
Hi Naresh,
You can modify the "plotStructure" function to plot the bars with varying thickness in the following way:
function plotStructure(nodes,bars,options)
% Plot nodes
if options.nodeOn == 1
scatter3(nodes(:,1),nodes(:,2),nodes(:,3),10,'filled','MarkerEdgeColor','k','MarkerFaceColor','k')
end
% Plot bars
barX = [nodes(bars(:,1),1) nodes(bars(:,2),1)]';
barY = [nodes(bars(:,1),2) nodes(bars(:,2),2)]';
barZ = [nodes(bars(:,1),3) nodes(bars(:,2),3)]';
hold on
if ~isempty(options.barColor) && ~isempty(options.barWidth)
for b=1:size(bars,1)
line(barX(:,b),barY(:,b),barZ(:,b),'Color',options.barColor(b,:),'LineWidth',options.barWidth(b))
end
else
line(barX,barY,barZ,'Color','k')
end
hold off
% Other figure properties
gridMin = min(nodes);
gridMax = max(nodes);
xlim([gridMin(1) gridMax(1)])
ylim([gridMin(2) gridMax(2)])
zlim([gridMin(3) gridMax(3)])
pbaspect([1 1 gridMax(3)/gridMax(2)])
view(options.viewAngle(1),options.viewAngle(2))
axis off
end
To use the modified plotStructure function, you need to add an additional property “options.barWidth” to the options structure. This property will be passed as an input argument to plotStructure, similar to how the color of each bar is passed through “options.barColor”. The “options.barWidth” property must be a column vector with the thickness value for each bar, in the same order as the bars in the bars input matrix.
  댓글 수: 3
Saffan
Saffan 2023년 6월 7일
Hi Naresh,
Make sure that options.barWidth property is a vector of size numOfBars x 1.
Here is a sampe code snippet where I have modified example_diagrid.m file to call the modified function:
options.barColor = [repmat([0 0 1],vars.nDiags/2,1); ...
repmat([1 0 0],vars.nDiags/2,1); ...
repmat([1 1 0],vars.nBeams,1)];
exampleWidthVector = linspace(1,2.4,1080)';
options.barWidth =exampleWidthVector;
plotStructure(nodes,bars,options)
I hope this helps.
Naresh Koju
Naresh Koju 2023년 6월 12일
Thank you Saffan for all your help. I had the options.barWidth property defined with a vector size of numOfBars x 1. I feel that the lineWidth variation is just not too large for me to be visibily distinguishable.
Thanks
Naresh

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by