How do you plot two graphs on the same figure with a loop?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Adam Danz
am 8 Apr. 2019
Bearbeitet: Adam Danz
am 8 Apr. 2019
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.
Antworten (0)
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!