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

1 vue (au cours des 30 derniers jours)
Monique Embury
Monique Embury le 4 Avr 2019
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 commentaires
Adam Danz
Adam Danz le 8 Avr 2019
Modifié(e) : Adam Danz le 8 Avr 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.
Monique Embury
Monique Embury le 9 Avr 2019
Thank you Adam. It seems as though the loop is not gathering the values calculated from my displacement command earlier.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by