image thumbnail
from Pore Pressure Plotting by WaiChing Sun
Plotting Function for OpenSees Model.

undeformplot=undeformplot
% ---------------------------------------------------------------------------------------
% Pacific Earthquake Enginering Research Center Summer Intern Research Project
% item 3
% 
%  Written by: WaiChing Sun [stvsun@ucdavis.edu]
%     Purpose: generate the animation that visualize the motions
%              of the structures composed by beam or quad 
%       Input: One input file that recorded the node coordinates
%              Files that recorded the motion of every nodes
%      Output: the movie on a new figure as well as a avi output
%              file.
%      Notice: THe following command has been added in order to 
%              recrod all nodes displacement in one input file.
%----------------------------------------------------------------------------------------
% set nodeList {}
% for {set i 1} {$i <= 76} {incr i 1} {
%  lappend nodeList $i
% }
% eval "recorder Node AllXDispforStories.out disp -time -node $nodeList -dof 1-dT 0.025"
% eval "recorder Node AllYDispforStories.out disp -time -node $nodeList -dof 1-dT 0.025"
% Last Update: 7/15/2004
%----------------------------------------------------------------------------------------
function undeformplot=undeformplot

clear all;
%mov=avifile('test','compression','indeo5'); 
% format long;
[filetag, pathname] = uigetfile('*.txt','Please open the node coordinate file *.txt',100,100);
[filetag1, pathname] = uigetfile('*.txt','Please Open the element file *.txt',100,100); 



answer = inputdlg({'Please enter the title of the plot',...
                   'Please name the x axis',...
                   'Please name the y axis'});
                   %{'Enter the intervals'});% ,[1 2 3 4],...
                   % {'xlowerlimit','xupperlimit','ylowerlimit','yupperlimit'});
display(answer);  
title(answer(1));
xlabel(answer(2));
ylabel(answer(3));

% Title and axis


nodecoord=load(filetag);
elecoord =load(filetag1);

% Test the size of the node displacement file

disp(size(elecoord));

% disp(scaleddisp);


%load framenodes.txt
% load multistorynodes.txt;
% load AllDispForStories.out;

%figure('units','normalized','outerposition',[0 0 1 1]); 

set(gcf,'defaulttextfontsize',10);
set(gcf,'defaultaxesfontsize',10);
set(gcf,'defaulttextfontname','Times');
set(gcf,'defaultaxesfontname','Times');
orient landscape;

[row, col] = size(nodecoord);

tag=nodecoord(1:row,1);
x=nodecoord(1:row, 2);
y=nodecoord(1:row, 3);

% display(tag);

% subplot('position',[0.05 0.2 0.9 0.3]);

% This part is aimed to draw the original view of the building
% hold on

drawswitch=size(elecoord);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% this proceduce is used to generate the best fix axis                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if (min(x) >= 0) 
    xmin= (min(x)-0.5*(max(x)+min(x)));%+min(scaleddispx));
    xmax= (1.5*max(x));%+max(scaleddispx));
elseif (min(x) <0) & (max(x) >=0)
    xmin = (1.5*min(x));
    xmax = (1.5*max(x));
else
    xmin= (1.5*min(x));%+min(scaleddispx));
    xmax= (0.5*max(x)); 
end
    
if (min(y) >= 0) 
    ymin= (0.5*min(y));%+min(scaleddispx));
    ymax= (1.2*max(y));%+max(scaleddispx));
elseif (min(y) <0) & (max(y) >=0)
    ymin = (1.5*min(y));
    ymax = (1.5*max(y));
else
    ymin= (1.5*min(y));%+min(scaleddispx));
    ymax= (0.5*max(y));    
end

%axis([xmin xmax ymin ymax]);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

prompt = {'Please enter the lower limit of the x axis below:',...
          'Please enter the upper limit of the x axis below:',...
          'Please enter the lower limit of the y axis below:',...
          'Please enter the upper limit of the y axis below:'};
def=  {num2str(xmin),num2str(xmax),num2str(ymin),num2str(ymax)};
dlgtitle ='Input for intervals';
limitanswer = inputdlg(prompt, dlgtitle,[1 2 3 4], def);

display(limitanswer);    
% figure;
axislimits =  str2double(limitanswer);
% display(axisstring);
% axislimits = eval(answer);
hold on;
axis(axislimits);
axis equal;
if (drawswitch(2)<4)
disp(' Case 1: beam element');
    for i = 1:1:(length(elecoord))
         
         x1 = x(elecoord(i,2));
         x2 = x(elecoord(i,3));
         y1 = y(elecoord(i,2));
         y2 = y(elecoord(i,3));
         xarray = [x1 x2];
         yarray = [y1 y2];
         
         plot(xarray,yarray,'EraseMode','background');
     end

%else


elseif (drawswitch(2)>4)&(drawswitch(2)<8)

    disp('Case 2: quad element');
    for i = 1:(length(elecoord))
        
  %x = [node(ele(i,2),2) node(ele(i,3),2) node(ele(i,4),2) node(ele(i,5),2) node(ele(i,2),2)];
   %y = [node(ele(i,2),3) node(ele(i,3),3) node(ele(i,4),3) node(ele(i,5),3) node(ele(i,2),3)]; 
   
      x1 = x(elecoord(i,2));
      x2 = x(elecoord(i,3));
      x3 = x(elecoord(i,4));
      x4 = x(elecoord(i,5));
      y1 = y(elecoord(i,2)); 
      y2 = y(elecoord(i,3)); 
      y3 = y(elecoord(i,4));
      y4 = y(elecoord(i,5));
      xarray = [x1 x2 x3 x4 x1];
      yarray = [y1 y2 y3 y4 y1];
      colorfill(i) = elecoord(i,6);
      plot(xarray,yarray,'k');
      fill(xarray,yarray,colorfill(i));
    end
end

Contact us at files@mathworks.com