Code covered by the BSD License  

Highlights from
Hydromat

from Hydromat by Baharuddin Ali
Plot the body plan of ship 2D-3D & hydrostatic

LeForm(file)
function LeForm(file)
global DST A0 A1 A3
file=uigetfile('D:\MatlabProg\Hydromat\*.txt');
fid=fopen(file,'r');
title=fgetl(fid); 
[uk]=fscanf(fid,'%f ',[1,5]);
Lgirth(file,uk(5));
fid=fopen('dokar2.txt','r');
[ukuranutama]=fscanf(fid,'%f ',[1,5]); % Ukuran utama kapal
for i=1:DST
   [jumdat]=fscanf(fid,'%f %f\n',[1,2]);         %Jumlah data dan No. ST
   [ttdat]=fscanf(fid,'%f %f\n',[2,jumdat(:,1)]); %data titik tiap ST
   ttk=ttdat';
   luasST=0;
   for j=1:jumdat(:,1)-1;
      % --------- Luas tiap ST ----------------------
      luas1=0.5*(ttk(j,2)+ttk(j+1,2))*(ttk(j+1,1)-ttk(j,1));
      luasST=luasST+luas1;
   end
   %luasST;							% Luas ST
   Bs= 2*ttk(jumdat(:,1),2);                            % Lebar pd draft tiap ST
   H0=Bs/2/(ttk(jumdat(1))-ttk(1,1));
   SIG=2*luasST/(Bs*(ttk(jumdat(1))-ttk(1,1)));
   E=(H0-1.0)/(H0+1.0);
   B=Bs/2;
   PARAM(H0,SIG,B);
   for I=1:21
      TH(I)=pi/40*(I-1);
      X(I)=(A0+A1)*sin(TH(I))-A3*sin(3.0*TH(I));
      Y(I)=(A1-A0)*cos(TH(I))-A3*cos(3.0*TH(I));
   end
   X(21)=Bs/2;
   Y(21)=0.0;
   I=1:21;
   %[(X(I))',(Y(I))']
   %pause
   if(jumdat(2)<=5)
     plot(-ttk(:,2),ttk(:,1),-X(I),Y(I)+uk(5),'r');hold on
  else  
     plot(ttk(:,2),ttk(:,1),X(I),Y(I)+uk(5),'r');hold on
	end
end
fclose(fid);
axis equal; legend('Body Plan','Lewis Form')
clear;

Contact us at files@mathworks.com