1function simplifiedVesselModelSim(time,eta0,nu0,tau,nu_c,MRB,MA,Bv,Dp,G)
 2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 3% Nonlinear Unified Seakeeping and Maneuvering Model without Fluid Memory,
 4% based on Perez & Fossen 2017.
 5%
 6%
 7%MISSING: Fluid memory and Cross-Flow Drag and Surge Resistance
 8%
 9% Author: Markus Fossdal 2018.
10%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11
12if time >= 20 && time <= 21
13%% Parameters
14% MRB = vessel.MRB; %Rigid-body mass matrix
15M = MRB + MA;
16M_inv = inv(M);%Rigid-body
17% MA = vesselABC.MA; %Added mass matrix
18% Bv = vessel.Bv; %Linear viscous damping matrix
19% Dp = vesselABC.Dp; %Linear potential damping matrix
20% G = vesselABC.G; % Stiffness matrix
21
22L = [0 0 0 0 0 0; %Selection matrix
23     0 0 0 0 0 1;
24     0 0 0 0 -1 0;
25     0 0 0 0 0 0;
26     0 0 0 0 0 0; 
27     0 0 0 0 0 0];
28
29
30nu_r = nu0-nu_c; %Relative velocity
31U_r = nu_r(1,1); %Relative speed
32CRB = U_r * MRB * L; % Linearized Coriolis Matrix
33CA = U_r*MA*L; %Added mass matrix
34
35J = 1;
36
37%% Computations
38
39%nu_dot = ;
40%[J,~,~] = eulerang(eta(1,4),eta(1,5),eta(1,6));
41%eta_dot = ;
42
43tspan = [0 50];
44y0 = [nu0 eta0];
45
46figure();
47[t,y] = ode45(@f,tspan,y0);
48
49
50u=5;
51end
52
53end
54
55function dydt = f(t,y)
56dydt = [M_inv*(tau -CRB*nu -CA*nu_r - (Bv+Dp)*nu_r - G*eta)
57                J*nu];
58            
59end
60