Matlab - DIBUJAR MALLADO MATLAB

 
Vista:
sin imagen de perfil

DIBUJAR MALLADO MATLAB

Publicado por Marta (2 intervenciones) el 10/05/2015 19:58:40
Hola,
necesito crear un programa en Matlab que dibuje un mallado.
La información de la que parto es el número de nodos y sus coordenadas, y el número de elmentos que forman las mallas y los nodos asociados a cada elemento.

¿Existe algún comando en Matlab que permita dibujar mallados partiendo de esa información?
Gracias.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Royeth
Val: 3.309
Plata
Ha mantenido su posición en Matlab (en relación al último mes)
Gráfica de Matlab

DIBUJAR MALLADO MATLAB

Publicado por Royeth (1818 intervenciones) el 11/05/2015 00:20:29
esta función de http://www.mathworks.com/matlabcentral/fileexchange/32719-postprocessing-in-fem/content/postprocessing/PlotMesh.m te puede servir :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
function PlotMesh(coordinates,nodes)
%--------------------------------------------------------------------------
% Purpose:
%         To plot the Finite Element Method Mesh
% Synopsis :
%           PlotMesh(coordinates,nodes)
% Variable Description:
%           coordinates - The nodal coordinates of the mesh
%           -----> coordinates = [node X Y Z] 
%           nodes - The nodal connectivity of the elements
%           -----> nodes = [elementNo node1 node2......]    
%
% NOTE : Please note that in coordinates ,displacements first column is 
%        node number and in nodes forst column is element number .
%--------------------------------------------------------------------------
 
dimension = size(coordinates(:,2:end),2) ;  % Dimension of the mesh
nel = length(nodes) ;                  % number of elements
nnode = length(coordinates) ;          % total number of nodes in system
nnel = size(nodes,2)-1;                % number of nodes per element
% 
% Initialization of the required matrices
X = zeros(nnel,nel) ;
Y = zeros(nnel,nel) ;
Z = zeros(nnel,nel) ;
 
if dimension == 3   % For 3D plots
 
for iel=1:nel
     for i=1:nnel
     nd(i)=nodes(iel,i+1);         % extract connected node for (iel)-th element
     X(i,iel)=coordinates(nd(i),2);    % extract x value of the node
     Y(i,iel)=coordinates(nd(i),3);    % extract y value of the node
     Z(i,iel)=coordinates(nd(i),4) ;   % extract z value of the node
     end
end
 
% Plotting the FEM mesh, display Node numbers and Element numbers
     figure
     plot3(X,Y,Z,'k')
     fill3(X,Y,Z,'w')
     rotate3d ;
     title('Finite Element Mesh') ;
     axis off ;
     k = nodes(:,2:end);
     nd = k' ;
    for i = 1:nel
     text(X(:,i),Y(:,i),Z(:,i),int2str(nd(:,i)),....
              'fontsize',8,'color','k');
   
      text(sum(X(:,i))/4,sum(Y(:,i))/4,sum(Z(:,i))/4,int2str(i),.....
                'fontsize',10,'color','r') ;
    end    
    
elseif dimension == 2           % For 2D plots

for iel=1:nel   
     for i=1:nnel
     nd(i)=nodes(iel,i+1);         % extract connected node for (iel)-th element
     X(i,iel)=coordinates(nd(i),2);    % extract x value of the node
     Y(i,iel)=coordinates(nd(i),3);    % extract y value of the node
     end
end
    
% Plotting the FEM mesh, diaplay Node numbers and Element numbers
     figure
     plot(X,Y,'k')
     fill(X,Y,'w')
     
     title('Finite Element Mesh') ;
     axis off ;
     k = nodes(:,2:end);
     nd = k' ;
    for i = 1:nel
     text(X(:,i),Y(:,i),int2str(nd(:,i)),'fontsize',8,'color','k');
     text(sum(X(:,i))/4,sum(Y(:,i))/4,int2str(i),'fontsize',10,'color','r') ;
    end
end


Saludos
https://www.facebook.com/royethmatlab
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

DIBUJAR MALLADO MATLAB

Publicado por Marta (2 intervenciones) el 11/05/2015 11:53:44
Hola,
Gracias por tu respuesta.
Pero al ejecutar el programa, Matlab devuelve el siguiente error
"Error: Function definitions are not permitted in this context."
¿Puede ser cosa dle programa?
Un saludo
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar