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

1 visualización (últimos 30 días)
Monique Embury
Monique Embury el 4 de Abr. de 2019
Comentada: Monique Embury el 9 de Abr. de 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 comentarios
Adam Danz
Adam Danz el 8 de Abr. de 2019
Editada: Adam Danz el 8 de Abr. de 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 el 9 de Abr. de 2019
Thank you Adam. It seems as though the loop is not gathering the values calculated from my displacement command earlier.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Graphics Performance en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by