% wforces.m --------------- Used in OC4213 Lab 1. ------ PC VERSION
% Calculates Drag Force and Inertial Force and their sum, the Total
% Wave Force on a vertical cylinder

stopprog=[];
uname = input('Please enter your name to use for a signature on plots: ','s');

while (isempty(stopprog) | (stopprog~='q'))

disp(' ');
!wforce.exe
load forces.dat
load label.dat
load labl.dat
ang=forces(:,1);fd=forces(:,2);fi=forces(:,3);ft=forces(:,4);
h=label(1);ht=label(2);t=label(3);d=label(4);z=label(5);
wl=labl(1);hl=labl(2);fmax=labl(3);amax=labl(4);
t1=[0 360];t2=[0 0];
m1=max(fd);m2=max(fi);m3=max(ft);
m3=[m1 m2 m3];
m=max(m3);
upper=m+100;
lower=-upper;
v=[0 360 lower upper];
figure; 
hq(1)=plot(ang(1:3:end),fd(1:3:end),'k*','markersize',2);
axis(v)
hold on
hq(2)=plot(ang,fi,'g--','linewidth',1.5);
hq(3)=plot(ang,ft,'r','linewidth',1.5);
plot(t1,t2)
ylabel('FD, FI, FTOT (Newtons)')
xlabel('Phase (degrees)')
title(['Depth = ',num2str(h),' m; Wave ht = ',num2str(ht),' m; T = ',...
num2str(t),' sec'])
text(95,upper/1.143,['Diameter = ',num2str(d),' m; Dist Below SWL = ',...
num2str(z),' m'])
text(95,upper/1.33,['Wave Length = ',num2str(wl),'; Relative Depth = ',...
num2str(hl)])
text(95,upper/1.6,['Total force max = ',num2str(fmax),' Newtons at ',...
num2str(amax),' degrees'])
%text(.15,.15,'green = FInertial','sc')
%text(15,lower+(upper-lower)/20,'green = FInertial')
%text(.15,.175,'white = FDrag','sc')
%text(15,lower+(upper-lower)/10,'white = FDrag')
%text(.15,.20,'red = FTotal','sc')
%text(15,lower+(upper-lower)/5,'red = FTotal')
%!rm label.dat
%!rm labl.dat
%!rm forces.dat
grid on;
signature(uname,'OC4213 Lab 1');
legend(hq,'FDrag','FInertial','FTotal',0);

stopprog = input('Enter q to quit, or hit RETURN to try new values: ','s');

end % while stopprog

   

