function ShowBackbone()
% Acquires the xyz data from the file 1bl8.dat
% and displays the backbone in 3-D

fid = fopen('1bl8.dat','r')
% Initialize the target vectors..
x=[];y=[];z=[];
while ~feof(fid)
% Get the next line from the file
s = fgetl(fid);
if strcmp(s(1:4),'ATOM')
% File lines that begin with 'ATOM' house xyz data
if strcmp(s(14:15),'CA')
% This atom is of interest--alpha carbon, part of the "backbone"
% Update the x, y, and z arrays...
x = [x;str2double(s(33:38))];
y = [y;str2double(s(41:46))];
z = [z;str2double(s(49:54))];
end
end
end
fclose(fid);
% Look at the protein...
ThreeDView(x,y,z)

function ThreeDView(x,y,z)
% Displays the polygonal line defined by the the n-vectors x, y, and z.
% Set up the display window...
close all
figure
set(gcf,'Position',[100 100 1000 800])
axis(1.1*[min(x) max(x) min(y) max(y) min(z) max(z)])
axis equal
axis manual
grid on
hold on
for i=1:length(x)-1
% Display the i-th amino acid
plot3([x(i) x(i+1)],[y(i) y(i+1)],[z(i) z(i+1)],'k')
plot3(x(i),y(i),z(i),'.r','Markersize',10)
pause(.02)
end
shg
pause(1)
set(gca,'color','k')
set(gcf,'color','k')
plot3(x,y,z,'m')
plot3(x,y,z,'.c','Markersize',10)
v = get(gca,'View');
% v is a2-vector. The first component is the azimuth of the view
for i=1:360
% increase the azimuth by one degree and update the view
v(1) = v(1)+1;
set(gca,'View',v)
pause(.05)
end