Varargout Estesi (Varargin) : Function
Varargout Estesi (Varargin) : Function
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Outputs from this function are returned to the command line.
function varargout = estesi_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% E; modulus of elasticity
% A: area of cross section
% L: length of bar
format SHORTENG
E=get(handles.elasticidad,'String');
E=str2num(E);
A=get(handles.area,'String');
A=str2num(A); % area for various sections
EA=E*A;
numberElements=size(elementNodes,1);
numberNodes=size(nodeCoordinates,1);
xx=nodeCoordinates(:,1);
yy=nodeCoordinates(:,2);
% for structure:
% displacements: displacement vector
% force : force vector
% stiffness: stiffness matrix
GDof=2*numberNodes;
U=zeros(GDof,1);
force=zeros(GDof,1);
% applied load at node 2
f4=get(handles.fuerza4,'String');
f4=str2num(f4);
force(4)=f4;
f8=get(handles.fuerza8,'String');
f8=str2num(f8);
force(8)=f8;
f12=get(handles.fuerza12,'String');
f12=str2num(f12);
force(12)=f12;
% solution
displacements=solution(GDof,prescribedDof,stiffness,force);
us=1:2:2*numberNodes-1;
vs=2:2:2*numberNodes;
% drawing displacements
%figure
%L=xx(2)-xx(1);
%L=node(2,1)-node(1,1);
%XX=displacements(us);YY=displacements(vs);
%dispNorm=max(sqrt(XX.^2+YY.^2));
%scaleFact=2*dispNorm;
%clf
%hold on
%drawingMesh(nodeCoordinates+scaleFact*[XX YY],...
% elementNodes,'L2','k.-');
%drawingMesh(nodeCoordinates,elementNodes,'L2','k.--');
% output displacements/reactions
%outputDisplacementsReactions(displacements,stiffness,...
% GDof,prescribedDof)
% displacements
disp('Displacements')
%displacements=displacements1;
jj=1:GDof; format
[jj' displacements]
% reactions
F=stiffness*displacements;
reactions=F(prescribedDof);
disp('reactions')
[prescribedDof reactions]
% stresses at elements
%---- stresses2Dtruss(numberElements,elementNodes,...
%--- xx,yy,displacements,E)
for e=1:numberElements
indice=elementNodes(e,:);
elementDof=[ indice(1)*2-1 indice(1)*2 indice(2)*2-1 indice(2)*2] ;
xa=xx(indice(2))-xx(indice(1));
ya=yy(indice(2))-yy(indice(1));
length_element=sqrt(xa*xa+ya*ya);
C=xa/length_element;
S=ya/length_element;
sigma(e)=E/length_element* ...
[-C -S C S]*displacements(elementDof);
sigma
cla(handles.plotFig);
plot(handles.plotFig,nodeCoordinates(:,1),nodeCoordinates(:,2),'o');
hold on;
dispXYZ = zeros(length(displacements)/2,2);
dispXYZ(:,1) = displacements(1:2:length(displacements)-1);
dispXYZ(:,2) = displacements(2:2:length(displacements));
display(dispXYZ)
nodeCoDis = nodeCoordinates+dispXYZ;
for i=1:length(elementNodes(:,1))
itmp = elementNodes(i,1);
jtmp = elementNodes(i,2);
xs = [nodeCoordinates(itmp,1) nodeCoordinates(jtmp,1)];
ys = [nodeCoordinates(itmp,2) nodeCoordinates(jtmp,2)];
xd = [nodeCoDis(itmp,1) nodeCoDis(jtmp,1)];
yd = [nodeCoDis(itmp,2) nodeCoDis(jtmp,2)];
disp('stresses')
sigma'
%%
set(handles.esfuerzos,'String',num2str(sigma'));
set(handles.reacciones,'String',num2str([prescribedDof reactions]));
set(handles.desplazamientos,'String',num2str([jj' displacements]));
function fuerza8_Callback(hObject, eventdata, handles)
% hObject handle to fuerza8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)