% MATLAB CODE: Example C-6
% Elasticity: Theory, Applications and Numerics - Elsevier
% M.H. Sadd, University of Rhode Island
% Generates 2-D Warping Displacement Contours for 
% Elliptical Section Under Torsion - Figure 9-8
clc, clear all
% Input Geometry and Angle of Twist
a=1.0; b=0.5; alpha=1.0;
% Input Grid Space
r=[0:0.05:1];
t=[0:pi/20:2*pi];
% Generate Contour Data
K=alpha*(b^2-a^2)/(a^2+b^2);
for i=1:length(r)
    for j=1:length(t)
        x(i,j)=a*r(i)*cos(t(j));
        y(i,j)=b*r(i)*sin(t(j));
        w(i,j)=K*x(i,j)*y(i,j);
    end
end
% Plotting Call with 20 Contours
contour(x,y,w,20,'k-');
axis equal

