필터 지우기
필터 지우기

How do you plot two graphs on the same figure with a loop?

조회 수: 1 (최근 30일)
Monique Embury
Monique Embury 2019년 4월 4일
댓글: Monique Embury 2019년 4월 9일
I am trying to plot the original mesh versus the deformed mesh on the same plot. I have used this loop to plot the original mesh earlier. I am trying to use it with some additonal code to plot both figures on the same graph. My displacement matrix is in the form of [ux1 uy1 ux2 uy2...etc.]. Currently I can only see one figure and it is green.
Thank you in advance.
%plots undeformed and deformed structure
function PlotMeshonMesh(coordinates,nodes,displacement)
nel = length(nodes); %number of elements
nnode = length(coordinates); %total number of nodes in system
nnel = size(nodes,2); %number of nodes per element
%
% empty required matrices
X = zeros(nnel,nel);
Y = zeros(nnel,nel);
Z = zeros(nnel,nel);
scalefactor=100;
%
for iel=1:nel
for i=1:nnel
nd(i)=nodes(iel,i); %extract connected node for (iel)-th element
X(i,iel)=coordinates(nd(i),1); %extract x value of the node
Y(i,iel)=coordinates(nd(i),2);%extract y value of the node
uX(i,iel)=coordinates(nd(i),1)+displacement(2*nnel-1,1)*scalefactor; %extract x value of the node with displacement
uY(i,iel)=coordinates(nd(i),2)+displacement(2*nnel,1)*scalefactor; %extract y value of the node with displacement
end
end
%Plotting the FEM mesh and profile of the given component
f4 = figure ;
set(f4,'name','Postprocessing','numbertitle','off') ;
plot(X,Y,'k',uX,uY,'g')
end
  댓글 수: 4
Adam Danz
Adam Danz 2019년 4월 8일
편집: Adam Danz 2019년 4월 8일
Maybe the values of ux and uy (which are shown on the plot in green) are much larger than x and Y (which do not appear on the plot). In other words, maybe X and Y are so tiny that you can't see them. Another possiblity is that they are empty. Yet another possibility is that they are exactly the same as ux and uy so they are plotted under the green lines.
Monique Embury
Monique Embury 2019년 4월 9일
Thank you Adam. It seems as though the loop is not gathering the values calculated from my displacement command earlier.

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

답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by