This Matlab code simulates ship rolling behavior in irregular waves and calculates the probability of capsizing for different sea states. It first generates irregular wave time series data and calculates wave parameters. It then uses the Runge-Kutta method to solve the ship rolling differential equation to obtain roll angle time series. Probability distributions and CDFs are plotted for wave amplitude, heeling moment, roll angle and righting moment. The code also calculates the probability of various failure events and compares the capsizing probability over different sea states.
This document estimates various ARMA models, including AR(1), MA(3), and ARMA(1,1) models, on time series data. It then evaluates these models along with a random walk model on out-of-sample forecasting performance. Key metrics computed include AIC, SBIC, parameter estimates, standard errors, Ljung-Box and LM test statistics, mean squared error of forecasts, and Diebold-Mariano test statistics to compare the ARMA and random walk forecasts.
Robust adaptive integral backstepping control and its implementation onShubhobrata Rudra
The document presents a robust adaptive integral backstepping control scheme for motion control systems. It describes the state model of the system and control objective of tracking a reference signal. An integral backstepping control design is developed using error variables and a control Lyapunov function. An adaptation scheme estimates parameter variations using a parameter update law. To improve robustness, a continuous switching function is used to prevent abnormal variation of the adaptation rates. Simulation results show the proposed robust adaptive controller has better tracking performance and reduces parameter estimation error compared to a standard adaptive controller.
This document describes an ECG simulator created in MATLAB. It uses Fourier series analysis to generate the typical waves that make up an ECG signal, including the P, Q, R, S and T waves. The simulator allows the user to input heart rate and amplitude/duration values for each wave. Code files implement functions to generate the individual waves based on Fourier series, which are then summed to produce the full ECG waveform. The output provides a simulated normal lead II ECG signal.
1. The document discusses discrete-time control systems, where variables can only change at discrete time intervals denoted by kT.
2. It explains that continuous signals must be sampled and quantified before being processed digitally. This involves sample-and-hold circuits and analog-to-digital converters.
3. Discrete-time control systems are classified based on whether the process is continuous or discrete. The most common are discrete-time controllers for continuous processes, which require discretizing analog signals.
Este documento proporciona una historia y descripción general de las diferentes versiones de Microsoft PowerPoint desde su creación en 1987 hasta la actualidad. Comenzó como un programa llamado Presenter desarrollado por Forethought para Apple II y luego fue adquirido por Microsoft en 1987, lanzando la primera versión de PowerPoint. Desde entonces, Microsoft ha lanzado periódicamente nuevas versiones con mejoras en características como animaciones, compatibilidad entre plataformas, edición de video e imágenes, y capacidades de colaboración en línea.
This document discusses decoding the sacred name of God, the Tetragrammaton (YHWH). It summarizes the biblical passages where God reveals his name to Moses, noting that "I AM THAT I AM" is a description of God's existence rather than a name. The main part of the document then examines the meaning of each letter in the Tetragrammaton to reveal the sacred name's interpretation and how it relates to improving morality and society.
This document estimates various ARMA models, including AR(1), MA(3), and ARMA(1,1) models, on time series data. It then evaluates these models along with a random walk model on out-of-sample forecasting performance. Key metrics computed include AIC, SBIC, parameter estimates, standard errors, Ljung-Box and LM test statistics, mean squared error of forecasts, and Diebold-Mariano test statistics to compare the ARMA and random walk forecasts.
Robust adaptive integral backstepping control and its implementation onShubhobrata Rudra
The document presents a robust adaptive integral backstepping control scheme for motion control systems. It describes the state model of the system and control objective of tracking a reference signal. An integral backstepping control design is developed using error variables and a control Lyapunov function. An adaptation scheme estimates parameter variations using a parameter update law. To improve robustness, a continuous switching function is used to prevent abnormal variation of the adaptation rates. Simulation results show the proposed robust adaptive controller has better tracking performance and reduces parameter estimation error compared to a standard adaptive controller.
This document describes an ECG simulator created in MATLAB. It uses Fourier series analysis to generate the typical waves that make up an ECG signal, including the P, Q, R, S and T waves. The simulator allows the user to input heart rate and amplitude/duration values for each wave. Code files implement functions to generate the individual waves based on Fourier series, which are then summed to produce the full ECG waveform. The output provides a simulated normal lead II ECG signal.
1. The document discusses discrete-time control systems, where variables can only change at discrete time intervals denoted by kT.
2. It explains that continuous signals must be sampled and quantified before being processed digitally. This involves sample-and-hold circuits and analog-to-digital converters.
3. Discrete-time control systems are classified based on whether the process is continuous or discrete. The most common are discrete-time controllers for continuous processes, which require discretizing analog signals.
Este documento proporciona una historia y descripción general de las diferentes versiones de Microsoft PowerPoint desde su creación en 1987 hasta la actualidad. Comenzó como un programa llamado Presenter desarrollado por Forethought para Apple II y luego fue adquirido por Microsoft en 1987, lanzando la primera versión de PowerPoint. Desde entonces, Microsoft ha lanzado periódicamente nuevas versiones con mejoras en características como animaciones, compatibilidad entre plataformas, edición de video e imágenes, y capacidades de colaboración en línea.
This document discusses decoding the sacred name of God, the Tetragrammaton (YHWH). It summarizes the biblical passages where God reveals his name to Moses, noting that "I AM THAT I AM" is a description of God's existence rather than a name. The main part of the document then examines the meaning of each letter in the Tetragrammaton to reveal the sacred name's interpretation and how it relates to improving morality and society.
Este documento resume las funciones clave de la administración para una empresa de restaurante. Explica que el gerente debe establecer un objetivo y estrategias como satisfacer las necesidades de los clientes vendiendo comida y obtener ganancias. También debe determinar la ubicación, proveedores y publicidad. Luego, el gerente debe organizar la estructura de la empresa asignando tareas a los empleados, estableciendo procesos y una jerarquía para tomar decisiones.
This document summarizes a Coursera course on strategy formulation. It lists the assignments, quizzes, and grading structure. The course consists of 6 modules on topics like industry analysis, resources and capabilities, and strategic decision making. Students must pass a certain number of graded assignments, which include quizzes, peer-graded assignments, and reviews of peers' work, in order to pass the course. Due dates are provided for each assignment and there is no penalty for late work, as long as all assignments are completed before the session ends.
The document discusses the benefits of exercise for mental health. Regular physical activity can help reduce anxiety and depression and improve mood and cognitive function. Exercise causes chemical changes in the brain that may help protect against mental illness and improve symptoms.
This document provides an overview of how life insurance can help people achieve financial security at different stages of life. It discusses the different types of life insurance products offered by OneAmerica companies, including whole life, term life, and universal life insurance. It explains the benefits these products provide, such as death benefits, cash value accumulation, and living benefits. The document aims to help readers understand how life insurance can help meet goals for estate planning, income replacement, education funding, and more.
Succession planning often falls from the agenda in a difficult economic climate when companies are downsizing or experiencing a recruitment freeze. The truth, however, is that in times like these, succession planning really is a critical activity that should not be overlooked.
El documento habla sobre la tecnología y su definición como el conjunto de conocimientos y técnicas aplicadas de forma lógica para modificar el entorno material y virtual. También menciona la ética como el estudio de la bondad y maldad de los comportamientos humanos. Finalmente, discute sobre delitos informáticos como la violación de datos personales y el uso de software malicioso.
Este documento presenta dos proyectos de robótica educativa diseñados por Amandy Ruiz Muñoz para el primer y sexto grado. El proyecto del primer grado involucra la construcción de un conejo movible llamado Tío Rabbit utilizando poleas correas, sensores de sonido y contacto. El proyecto del sexto grado implica la creación de un barco explorador oceánico y un robot explorador utilizando poleas compuestas, sensores de color y ultrasonido. Ambos proyectos se decoran con materiales reciclables y se
The document describes an algorithm to optimize drill bit design. It involves calculating pressure gradients in the pipe and annulus, pressure loss at the drill bit, and selecting an optimal flow rate and nozzle area. The algorithm performs these calculations over a range of flow rates to determine the optimum hydraulic path that maximizes a selection criterion like maximum jet impact force or drill bit horsepower. It then calculates the pump pressure and nozzle area needed to achieve this optimum flow rate and bit pressure loss.
This document defines functions for forward kinematics, inverse kinematics, and Jacobian calculations for a 4 link robot arm. It first defines link transformation and velocity propagation functions. It then performs (1) forward kinematics by multiplying link transforms to find the end effector transform, (2) inverse kinematics algebraically, and (3) calculates the angular and linear velocities at each joint and end effector to derive the Jacobian. Symbolic variables are used and simplified to provide readable output.
This MATLAB code provides an example of plotting a truncated Fourier series representation of a square wave signal. It computes the Fourier series in both complex exponential form (yce) and trigonometric form (yt) up to the Nth term, where N is an odd integer. It plots the original square wave, the truncated Fourier series approximations yce and yt, and their amplitude and phase spectra. The code demonstrates how to calculate and visualize truncated Fourier series representations of a periodic signal.
LAB05ex1.m
function LAB05ex1
m = 1; % mass [kg]
k = 4; % spring constant [N/m]
omega0=sqrt(k/m);
y0=0.1; v0=0; % initial conditions
[t,Y]=ode45(@f,[0,10],[y0,v0],[],omega0); % solve for 0<t<10
y=Y(:,1); v=Y(:,2); % retrieve y, v from Y
figure(1); plot(t,y,'b+-',t,v,'ro-'); % time series for y and v
grid on;
%------------------------------------------------------
function dYdt= f(t,Y,omega0)
y = Y(1); v= Y(2);
dYdt = [v; -omega0^2*y];
__MACOSX/._LAB05ex1.m
LAB05ex1a.m
function LAB05ex1a
m = 1; % mass [kg]
k = 4; % spring constant [N/m]
c = 1; % friction coefficient [Ns/m]
omega0 = sqrt(k/m); p = c/(2*m);
y0 = 0.1; v0 = 0; % initial conditions
[t,Y]=ode45(@f,[0,10],[y0,v0],[],omega0,p); % solve for 0<t<10
y=Y(:,1); v=Y(:,2); % retrieve y, v from Y
figure(1); plot(t,y,'b+-',t,v,'ro-'); % time series for y and v
grid on
%------------------------------------------------------
function dYdt= f(t,Y,omega0,p)
y = Y(1); v= Y(2);
dYdt = [v; ?? ]; % fill-in dv/dt
__MACOSX/._LAB05ex1a.m
MAT275_LAB05.pdf
MATLAB sessions: Laboratory 5
MAT 275 Laboratory 5
The Mass-Spring System
In this laboratory we will examine harmonic oscillation. We will model the motion of a mass-spring
system with differential equations.
Our objectives are as follows:
1. Determine the effect of parameters on the solutions of differential equations.
2. Determine the behavior of the mass-spring system from the graph of the solution.
3. Determine the effect of the parameters on the behavior of the mass-spring.
The primary MATLAB command used is the ode45 function.
Mass-Spring System without Damping
The motion of a mass suspended to a vertical spring can be described as follows. When the spring is
not loaded it has length ℓ0 (situation (a)). When a mass m is attached to its lower end it has length ℓ
(situation (b)). From the first principle of mechanics we then obtain
mg︸︷︷︸
downward weight force
+ −k(ℓ − ℓ0)︸ ︷︷ ︸
upward tension force
= 0. (L5.1)
The term g measures the gravitational acceleration (g ≃ 9.8m/s2 ≃ 32ft/s2). The quantity k is a spring
constant measuring its stiffness. We now pull downwards on the mass by an amount y and let the mass
go (situation (c)). We expect the mass to oscillate around the position y = 0. The second principle of
mechanics yields
mg︸︷︷︸
weight
+ −k(ℓ + y − ℓ0)︸ ︷︷ ︸
upward tension force
= m
d2(ℓ + y)
dt2︸ ︷︷ ︸
acceleration of mass
, i.e., m
d2y
dt2
+ ky = 0 (L5.2)
using (L5.1). This ODE is second-order.
(a) (b) (c) (d)
y
ℓ
ℓ0
m
k
γ
Equation (L5.2) is rewritten
d2y
dt2
+ ω20y = 0 (L5.3)
c⃝2011 Stefania Tracogna, SoMSS, ASU
MATLAB sessions: Laboratory 5
where ω20 = k/m. Equation (L5.3) models simple harmonic motion. A numerica ...
This document provides solutions to problems from a numerical methods textbook. It includes MATLAB code and step-by-step workings for problems related to numerical integration, differential equations, curve fitting, and other numerical methods topics. Solutions are provided for single-step and multi-step problems across 10 chapters. MATLAB code demonstrates the numerical methods and allows plotting of model outputs and errors. Equations, tables, and plots are used to show the results of applying numerical techniques to example problems.
Incorporate the SOR method in the multigridTest-m and apply the multig.pdfaartechindia
Incorporate the SOR method in the multigridTest.m and apply the multigridTest.m, to
determine the effects of changes in
Pre-smoothing iterations
Post-smoothing iterations
Multigrid cycle type
Iterative method
Number of grids (or grid hierarchy)
% SOR (Successive Over-Relaxation)
n = input('Enter number of equations, n: ');
A = zeros(n,n+1);
x1 = zeros(1,n);
A=[5 -2 3 -1;-3 9 1 2;2 -1 -7 3];
x1 = [0 0 0];
tol = input('Enter tolerance, tol: ');
m = input('Enter maximum number of iterations, m: ');
w = input('Enter the parameter w (omega): ');
k = 1;
while k <= m
err = 0;
for i = 1 : n
s = 0;
for j = 1 : n
s = s-A(i,j)*x1(j);
end
s = w*(s+A(i,n+1))/A(i,i);
if abs(s) > err
err = abs(s);
end
x1(i) = x1(i)+s;
end
if err <= tol
break;
else
k = k+1;
end
end
fprintf('The solution vector after %d iterations is :\n', k);
for i = 1 : n
fprintf(' %11.8f \n', x1(i));
end
%% Multigrid test case with visulization
% Author: Ben Beaudry
clc; clear; close all
load A_b.mat;
A = full(A); % Unsparce matrix to show full power of Multigrid
pre = 2; % Number of presmoothing iterations
post = 2; % Number of postsmoothing iterations
% cycle = 1; % Type of multigrid cycle (1=V-cycle, 2=W-cycle, 3=F-cycle)
smooth = 1; % Smoother type (1=Jacobi, 2=Gauss-Seidel)
grids = 5; % Max grids in cycle
maxit = 10; % Max iterations of solver
tol = 1e-02; % Tolerance of solver
%% Solvers
% solve directly
t=cputime;
x_D = A\b;
fprintf('Direct Solve Time: %g Seconds\n',cputime-t)
% V-Cycle
t=cputime;
[x_V,res_V,it_V] = multigrid(A,b,pre,post,1,smooth,grids,maxit,tol);
fprintf('V-Cycle Solve Time: %g Seconds\n',cputime-t)
% W-Cycle
t=cputime;
[x_W,res_W,it_W] = multigrid(A,b,pre,post,2,smooth,grids,maxit,tol);
fprintf('W-Cycle Solve Time: %g Seconds\n',cputime-t)
% F-Cycle
t=cputime;
[x_F,res_F,it_F] = multigrid(A,b,pre,post,3,smooth,grids,maxit,tol);
fprintf('F-Cycle Solve Time: %g Seconds\n',cputime-t)
% max it for iterative methods
it = 100;
% Gauss-Siedel
t=cputime;
L = tril(A);
U = triu(A,1);
x_G = zeros(length(b),1);
res_G= zeros(it,1);
for g = 1:it
x_G = L\(b-U*x_G);
r = b - A * x_G;
res_G(g) = norm(r);
if res_G(g) < tol
break;
end
end
fprintf('Gauss-Seidel Solve Time: %g Seconds\n',cputime-t)
% Jacobi
t=cputime;
d = diag(A);
dinv = 1./d;
LU = tril(A,-1)+triu(A,1);
U = triu(A,1);
x_J = zeros(length(b),1);
res_J= zeros(it,1);
for j = 1:it
x_J = dinv.*(b-(LU*x_J));
r = b - A * x_J;
res_J(j) = norm(r);
if res_J(j) < tol
break;
end
end
fprintf('Jacobi Solve Time: %g Seconds\n',cputime-t)
%% Plotting
figure;
hold on
plot(1:g,res_G(1:g),'o-','DisplayName','Guass-Seidel')
plot(1:j,res_J(1:j),'o-','DisplayName','Jacobi')
plot(1:it_V,res_V(1:it_V),'o-','DisplayName','V-Cycle Multigrid')
plot(1:it_F,res_F(1:it_F),'o-','DisplayName','F-Cycle Multigrid')
plot(1:it_W,res_W(1:it_W),'o-','DisplayName','W-Cycle Multigrid')
set(gca,'XLim',[0 100]);
grid on
legend('location','best')
ylabel('Relative Convergance')
xlabel('Iterations')
title('Convergance of Numerical System')
hold off
MULTIGRID FUNC.
This document contains code for calculating surge and swab pressures in an oil well. It takes inputs like pipe dimensions, fluid properties, flow rates, and calculates parameters like pressure losses and optimal flow rate. The code contains sections for calculating pressures at different flow rates, plotting the well dynamics, and determining the optimum hydraulic path and flow rate that balances maximum pump pressure with nozzle area and bit pressure loss.
Two Dimensional Unsteady Heat Conduction in T-shaped Plate.pdfShehzaib Yousuf Khan
This document defines the geometry and boundary conditions for a transient heat transfer simulation of a T-shaped plate. It discretizes the domain into uniform elements and initializes the temperature field. It then performs explicit time stepping using the heat equation, updating temperatures at the interior nodes of each sub-domain and along their interface at each time step. The simulation runs until a stopping criteria is met, outputting temperature contour plots at each iteration.
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdfmeerobertsonheyde608
Consider a 4-Link robot manipulator shown below. Use the forward kinematic D-H table and
write an m file that plots the manipulator. The instructions are given in the module 6. Submit
your solutions by the due date, in a single MATLAB m file.
Solution
Please give the kinetic D-H table else it would be difficult to code as we need to know the
rotation spin axis and other momentum of manipulator
Stating a general example code for manipulator with data
function X = fwd_kin(q,x)
% given a position in the configuration space, calculate the position of
% the end effector in the workspace for a two-link manipulator.
% q: vector of joint positions
% x: design vector (link lengths)
% X: end effector position in cartesian coordinates
% configuration space coordinates:
q1 = q(1); % theta 1
q2 = q(2); % theta 2
% manipulator parameters:
l1 = x(1); % link 1 length
l2 = x(2); % link 2 length
% calculate end effector position:
X = [l1*cos(q1) + l2*cos(q1+q2)
l1*sin(q1) + l2*sin(q1+q2)];
% SimulateTwolink.m uses inverse dynamics to simulate the torque
% trajectories required for a two-link planar robotic manipulator to follow
% a prescribed trajectory. It also computes total energy consumption. This
% code is provided as supplementary material for the paper:
%
% \'Engineering System Co-Design with Limited Plant Redesign\'
% Presented at the 8th AIAA Multidisciplinary Design Optimization
% Specialist Conference, April 2012.
%
% The paper is available from:
%
% http://systemdesign.illinois.edu/publications/All12a.pdf
%
% Here both the physical system design and control system design are
% considered simultaneously. Manipulator link length and trajectory
% specification can be specified, and torque trajectory and energy
% consumption are computed based on this input. It was found that maximum
% torque and total energy consumption calculated using inverse dynamics
% agreed closely with results calculated using feedback linearization, so
% to simplify optimization problem solution an inverse dynamics approach
% was used, which reduces the control design vector to just the trajectory
% design.
%
% In the conference paper several cases are considered, each with its own
% manipulator task, manipulator design, and trajectory design. The
% specifications for each of these five cases are provided here, and can be
% explored by changing the case number variable (cn).
%
% This code was incorporated into a larger optimization project. The code
% presented here includes only the analysis portion of the code, no
% optimization.
%
% A video illustrating the motion of each of these five cases is available
% on YouTube:
%
% http://www.youtube.com/watch?v=OR7Y9-n5SjA
%
% Author: James T. Allison, Assistant Professor, University of Illinois at
% Urbana-Champaign
% Date: 4/10/12
clear;clc
% simulation parameters:
p.dt = 0.0005; % simulation step size
tf = 2; p.tf = tf; % final time
p.ploton = 0; % turn off additional plotting capabilities
p.ploton2 = 0;
p.Tallow = 210; % maximum .
This document models and simulates the acceleration of a GM EV1 electric vehicle from 0 to 60 mph using MATLAB. It considers three mass scenarios: the base mass of 1560kg, a reduced mass of 1326kg, and an increased mass of 1794kg. The acceleration is modeled in two phases using differential equations. Simulation results show that acceleration decreases as mass increases, with times to reach 60 mph being 9.1, 7.8, and 10.5 seconds respectively. A mathematical solution to the differential equations is also derived and verified against MATLAB simulations, showing close matches.
This document provides Matlab code examples for modeling various receiver non-idealities including additive white Gaussian noise, carrier frequency offset, phase noise, I/Q imbalances, automatic gain control, sampling clock offset, and clipping and quantization. The code shows how to apply these non-idealities to an input signal in sequence to generate a simulated received signal. Parameters for each non-ideality can be configured and the code outputs both the processed signal and information about the non-ideality parameters.
1. Various common signals were generated using MATLAB, including unit impulse, unit step, ramp, sinc, sine, sawtooth, square, and triangular signals. Both continuous and discrete forms were produced.
2. Operations on the generated signals included plotting their amplitude over time or index, adding titles and labels to figures, and displaying the results in different subplot configurations for comparison.
3. Common periodic signals like sine and square waves were generated along with aperiodic signals such as ramp, impulse and step functions to demonstrate the creation of basic continuous and discrete time signals in MATLAB for analysis and simulation.
The document discusses equations for open channel flow and methods to calculate parameters for different channel cross section shapes including trapezoidal, circular, parabolic, and natural channels. It provides equations for area, perimeter, and their derivatives with respect to depth (y) for each cross section shape. Methods using the Newton-Raphson technique are presented to calculate the normal depth (y) given inputs of discharge (q), channel properties, slope and Manning's roughness coefficient. Outputs from the methods include normal depth, area, wetted perimeter, hydraulic radius, mean depth, mean velocity, energy, Froude number and more. Python code implementing the Newton-Raphson method for each cross section shape is also presented.
This document discusses phase lead and lag compensators for digital control systems. It covers:
1. Designing a discrete-time phase lead/lag compensator by mapping the z-plane to the w-plane using bilinear transformation.
2. Defining phase lead and lag compensators based on the positions of poles and zeros in the w-domain transfer function.
3. A design approach using frequency response methods to meet a phase margin specification by determining the parameters of a first-order digital phase lead or lag compensator.
4. Examples of designing phase lead and lag compensators for different plant transfer functions to meet specifications on phase margin and steady state error.
This document discusses different methods for discretizing a continuous time DC servo motor transfer function for use in digital control. It provides the transfer functions obtained when discretizing the motor model using various methods like zero order hold, impulse invariant mapping, Tustin's approximation, and zero pole matching at a sample time of 0.05 seconds. A plot compares the step responses of the closed loop system using these different discretization methods, showing they provide similar performance with small differences.
Este documento resume las funciones clave de la administración para una empresa de restaurante. Explica que el gerente debe establecer un objetivo y estrategias como satisfacer las necesidades de los clientes vendiendo comida y obtener ganancias. También debe determinar la ubicación, proveedores y publicidad. Luego, el gerente debe organizar la estructura de la empresa asignando tareas a los empleados, estableciendo procesos y una jerarquía para tomar decisiones.
This document summarizes a Coursera course on strategy formulation. It lists the assignments, quizzes, and grading structure. The course consists of 6 modules on topics like industry analysis, resources and capabilities, and strategic decision making. Students must pass a certain number of graded assignments, which include quizzes, peer-graded assignments, and reviews of peers' work, in order to pass the course. Due dates are provided for each assignment and there is no penalty for late work, as long as all assignments are completed before the session ends.
The document discusses the benefits of exercise for mental health. Regular physical activity can help reduce anxiety and depression and improve mood and cognitive function. Exercise causes chemical changes in the brain that may help protect against mental illness and improve symptoms.
This document provides an overview of how life insurance can help people achieve financial security at different stages of life. It discusses the different types of life insurance products offered by OneAmerica companies, including whole life, term life, and universal life insurance. It explains the benefits these products provide, such as death benefits, cash value accumulation, and living benefits. The document aims to help readers understand how life insurance can help meet goals for estate planning, income replacement, education funding, and more.
Succession planning often falls from the agenda in a difficult economic climate when companies are downsizing or experiencing a recruitment freeze. The truth, however, is that in times like these, succession planning really is a critical activity that should not be overlooked.
El documento habla sobre la tecnología y su definición como el conjunto de conocimientos y técnicas aplicadas de forma lógica para modificar el entorno material y virtual. También menciona la ética como el estudio de la bondad y maldad de los comportamientos humanos. Finalmente, discute sobre delitos informáticos como la violación de datos personales y el uso de software malicioso.
Este documento presenta dos proyectos de robótica educativa diseñados por Amandy Ruiz Muñoz para el primer y sexto grado. El proyecto del primer grado involucra la construcción de un conejo movible llamado Tío Rabbit utilizando poleas correas, sensores de sonido y contacto. El proyecto del sexto grado implica la creación de un barco explorador oceánico y un robot explorador utilizando poleas compuestas, sensores de color y ultrasonido. Ambos proyectos se decoran con materiales reciclables y se
The document describes an algorithm to optimize drill bit design. It involves calculating pressure gradients in the pipe and annulus, pressure loss at the drill bit, and selecting an optimal flow rate and nozzle area. The algorithm performs these calculations over a range of flow rates to determine the optimum hydraulic path that maximizes a selection criterion like maximum jet impact force or drill bit horsepower. It then calculates the pump pressure and nozzle area needed to achieve this optimum flow rate and bit pressure loss.
This document defines functions for forward kinematics, inverse kinematics, and Jacobian calculations for a 4 link robot arm. It first defines link transformation and velocity propagation functions. It then performs (1) forward kinematics by multiplying link transforms to find the end effector transform, (2) inverse kinematics algebraically, and (3) calculates the angular and linear velocities at each joint and end effector to derive the Jacobian. Symbolic variables are used and simplified to provide readable output.
This MATLAB code provides an example of plotting a truncated Fourier series representation of a square wave signal. It computes the Fourier series in both complex exponential form (yce) and trigonometric form (yt) up to the Nth term, where N is an odd integer. It plots the original square wave, the truncated Fourier series approximations yce and yt, and their amplitude and phase spectra. The code demonstrates how to calculate and visualize truncated Fourier series representations of a periodic signal.
LAB05ex1.m
function LAB05ex1
m = 1; % mass [kg]
k = 4; % spring constant [N/m]
omega0=sqrt(k/m);
y0=0.1; v0=0; % initial conditions
[t,Y]=ode45(@f,[0,10],[y0,v0],[],omega0); % solve for 0<t<10
y=Y(:,1); v=Y(:,2); % retrieve y, v from Y
figure(1); plot(t,y,'b+-',t,v,'ro-'); % time series for y and v
grid on;
%------------------------------------------------------
function dYdt= f(t,Y,omega0)
y = Y(1); v= Y(2);
dYdt = [v; -omega0^2*y];
__MACOSX/._LAB05ex1.m
LAB05ex1a.m
function LAB05ex1a
m = 1; % mass [kg]
k = 4; % spring constant [N/m]
c = 1; % friction coefficient [Ns/m]
omega0 = sqrt(k/m); p = c/(2*m);
y0 = 0.1; v0 = 0; % initial conditions
[t,Y]=ode45(@f,[0,10],[y0,v0],[],omega0,p); % solve for 0<t<10
y=Y(:,1); v=Y(:,2); % retrieve y, v from Y
figure(1); plot(t,y,'b+-',t,v,'ro-'); % time series for y and v
grid on
%------------------------------------------------------
function dYdt= f(t,Y,omega0,p)
y = Y(1); v= Y(2);
dYdt = [v; ?? ]; % fill-in dv/dt
__MACOSX/._LAB05ex1a.m
MAT275_LAB05.pdf
MATLAB sessions: Laboratory 5
MAT 275 Laboratory 5
The Mass-Spring System
In this laboratory we will examine harmonic oscillation. We will model the motion of a mass-spring
system with differential equations.
Our objectives are as follows:
1. Determine the effect of parameters on the solutions of differential equations.
2. Determine the behavior of the mass-spring system from the graph of the solution.
3. Determine the effect of the parameters on the behavior of the mass-spring.
The primary MATLAB command used is the ode45 function.
Mass-Spring System without Damping
The motion of a mass suspended to a vertical spring can be described as follows. When the spring is
not loaded it has length ℓ0 (situation (a)). When a mass m is attached to its lower end it has length ℓ
(situation (b)). From the first principle of mechanics we then obtain
mg︸︷︷︸
downward weight force
+ −k(ℓ − ℓ0)︸ ︷︷ ︸
upward tension force
= 0. (L5.1)
The term g measures the gravitational acceleration (g ≃ 9.8m/s2 ≃ 32ft/s2). The quantity k is a spring
constant measuring its stiffness. We now pull downwards on the mass by an amount y and let the mass
go (situation (c)). We expect the mass to oscillate around the position y = 0. The second principle of
mechanics yields
mg︸︷︷︸
weight
+ −k(ℓ + y − ℓ0)︸ ︷︷ ︸
upward tension force
= m
d2(ℓ + y)
dt2︸ ︷︷ ︸
acceleration of mass
, i.e., m
d2y
dt2
+ ky = 0 (L5.2)
using (L5.1). This ODE is second-order.
(a) (b) (c) (d)
y
ℓ
ℓ0
m
k
γ
Equation (L5.2) is rewritten
d2y
dt2
+ ω20y = 0 (L5.3)
c⃝2011 Stefania Tracogna, SoMSS, ASU
MATLAB sessions: Laboratory 5
where ω20 = k/m. Equation (L5.3) models simple harmonic motion. A numerica ...
This document provides solutions to problems from a numerical methods textbook. It includes MATLAB code and step-by-step workings for problems related to numerical integration, differential equations, curve fitting, and other numerical methods topics. Solutions are provided for single-step and multi-step problems across 10 chapters. MATLAB code demonstrates the numerical methods and allows plotting of model outputs and errors. Equations, tables, and plots are used to show the results of applying numerical techniques to example problems.
Incorporate the SOR method in the multigridTest-m and apply the multig.pdfaartechindia
Incorporate the SOR method in the multigridTest.m and apply the multigridTest.m, to
determine the effects of changes in
Pre-smoothing iterations
Post-smoothing iterations
Multigrid cycle type
Iterative method
Number of grids (or grid hierarchy)
% SOR (Successive Over-Relaxation)
n = input('Enter number of equations, n: ');
A = zeros(n,n+1);
x1 = zeros(1,n);
A=[5 -2 3 -1;-3 9 1 2;2 -1 -7 3];
x1 = [0 0 0];
tol = input('Enter tolerance, tol: ');
m = input('Enter maximum number of iterations, m: ');
w = input('Enter the parameter w (omega): ');
k = 1;
while k <= m
err = 0;
for i = 1 : n
s = 0;
for j = 1 : n
s = s-A(i,j)*x1(j);
end
s = w*(s+A(i,n+1))/A(i,i);
if abs(s) > err
err = abs(s);
end
x1(i) = x1(i)+s;
end
if err <= tol
break;
else
k = k+1;
end
end
fprintf('The solution vector after %d iterations is :\n', k);
for i = 1 : n
fprintf(' %11.8f \n', x1(i));
end
%% Multigrid test case with visulization
% Author: Ben Beaudry
clc; clear; close all
load A_b.mat;
A = full(A); % Unsparce matrix to show full power of Multigrid
pre = 2; % Number of presmoothing iterations
post = 2; % Number of postsmoothing iterations
% cycle = 1; % Type of multigrid cycle (1=V-cycle, 2=W-cycle, 3=F-cycle)
smooth = 1; % Smoother type (1=Jacobi, 2=Gauss-Seidel)
grids = 5; % Max grids in cycle
maxit = 10; % Max iterations of solver
tol = 1e-02; % Tolerance of solver
%% Solvers
% solve directly
t=cputime;
x_D = A\b;
fprintf('Direct Solve Time: %g Seconds\n',cputime-t)
% V-Cycle
t=cputime;
[x_V,res_V,it_V] = multigrid(A,b,pre,post,1,smooth,grids,maxit,tol);
fprintf('V-Cycle Solve Time: %g Seconds\n',cputime-t)
% W-Cycle
t=cputime;
[x_W,res_W,it_W] = multigrid(A,b,pre,post,2,smooth,grids,maxit,tol);
fprintf('W-Cycle Solve Time: %g Seconds\n',cputime-t)
% F-Cycle
t=cputime;
[x_F,res_F,it_F] = multigrid(A,b,pre,post,3,smooth,grids,maxit,tol);
fprintf('F-Cycle Solve Time: %g Seconds\n',cputime-t)
% max it for iterative methods
it = 100;
% Gauss-Siedel
t=cputime;
L = tril(A);
U = triu(A,1);
x_G = zeros(length(b),1);
res_G= zeros(it,1);
for g = 1:it
x_G = L\(b-U*x_G);
r = b - A * x_G;
res_G(g) = norm(r);
if res_G(g) < tol
break;
end
end
fprintf('Gauss-Seidel Solve Time: %g Seconds\n',cputime-t)
% Jacobi
t=cputime;
d = diag(A);
dinv = 1./d;
LU = tril(A,-1)+triu(A,1);
U = triu(A,1);
x_J = zeros(length(b),1);
res_J= zeros(it,1);
for j = 1:it
x_J = dinv.*(b-(LU*x_J));
r = b - A * x_J;
res_J(j) = norm(r);
if res_J(j) < tol
break;
end
end
fprintf('Jacobi Solve Time: %g Seconds\n',cputime-t)
%% Plotting
figure;
hold on
plot(1:g,res_G(1:g),'o-','DisplayName','Guass-Seidel')
plot(1:j,res_J(1:j),'o-','DisplayName','Jacobi')
plot(1:it_V,res_V(1:it_V),'o-','DisplayName','V-Cycle Multigrid')
plot(1:it_F,res_F(1:it_F),'o-','DisplayName','F-Cycle Multigrid')
plot(1:it_W,res_W(1:it_W),'o-','DisplayName','W-Cycle Multigrid')
set(gca,'XLim',[0 100]);
grid on
legend('location','best')
ylabel('Relative Convergance')
xlabel('Iterations')
title('Convergance of Numerical System')
hold off
MULTIGRID FUNC.
This document contains code for calculating surge and swab pressures in an oil well. It takes inputs like pipe dimensions, fluid properties, flow rates, and calculates parameters like pressure losses and optimal flow rate. The code contains sections for calculating pressures at different flow rates, plotting the well dynamics, and determining the optimum hydraulic path and flow rate that balances maximum pump pressure with nozzle area and bit pressure loss.
Two Dimensional Unsteady Heat Conduction in T-shaped Plate.pdfShehzaib Yousuf Khan
This document defines the geometry and boundary conditions for a transient heat transfer simulation of a T-shaped plate. It discretizes the domain into uniform elements and initializes the temperature field. It then performs explicit time stepping using the heat equation, updating temperatures at the interior nodes of each sub-domain and along their interface at each time step. The simulation runs until a stopping criteria is met, outputting temperature contour plots at each iteration.
Consider a 4-Link robot manipulator shown below. Use the forward kine.pdfmeerobertsonheyde608
Consider a 4-Link robot manipulator shown below. Use the forward kinematic D-H table and
write an m file that plots the manipulator. The instructions are given in the module 6. Submit
your solutions by the due date, in a single MATLAB m file.
Solution
Please give the kinetic D-H table else it would be difficult to code as we need to know the
rotation spin axis and other momentum of manipulator
Stating a general example code for manipulator with data
function X = fwd_kin(q,x)
% given a position in the configuration space, calculate the position of
% the end effector in the workspace for a two-link manipulator.
% q: vector of joint positions
% x: design vector (link lengths)
% X: end effector position in cartesian coordinates
% configuration space coordinates:
q1 = q(1); % theta 1
q2 = q(2); % theta 2
% manipulator parameters:
l1 = x(1); % link 1 length
l2 = x(2); % link 2 length
% calculate end effector position:
X = [l1*cos(q1) + l2*cos(q1+q2)
l1*sin(q1) + l2*sin(q1+q2)];
% SimulateTwolink.m uses inverse dynamics to simulate the torque
% trajectories required for a two-link planar robotic manipulator to follow
% a prescribed trajectory. It also computes total energy consumption. This
% code is provided as supplementary material for the paper:
%
% \'Engineering System Co-Design with Limited Plant Redesign\'
% Presented at the 8th AIAA Multidisciplinary Design Optimization
% Specialist Conference, April 2012.
%
% The paper is available from:
%
% http://systemdesign.illinois.edu/publications/All12a.pdf
%
% Here both the physical system design and control system design are
% considered simultaneously. Manipulator link length and trajectory
% specification can be specified, and torque trajectory and energy
% consumption are computed based on this input. It was found that maximum
% torque and total energy consumption calculated using inverse dynamics
% agreed closely with results calculated using feedback linearization, so
% to simplify optimization problem solution an inverse dynamics approach
% was used, which reduces the control design vector to just the trajectory
% design.
%
% In the conference paper several cases are considered, each with its own
% manipulator task, manipulator design, and trajectory design. The
% specifications for each of these five cases are provided here, and can be
% explored by changing the case number variable (cn).
%
% This code was incorporated into a larger optimization project. The code
% presented here includes only the analysis portion of the code, no
% optimization.
%
% A video illustrating the motion of each of these five cases is available
% on YouTube:
%
% http://www.youtube.com/watch?v=OR7Y9-n5SjA
%
% Author: James T. Allison, Assistant Professor, University of Illinois at
% Urbana-Champaign
% Date: 4/10/12
clear;clc
% simulation parameters:
p.dt = 0.0005; % simulation step size
tf = 2; p.tf = tf; % final time
p.ploton = 0; % turn off additional plotting capabilities
p.ploton2 = 0;
p.Tallow = 210; % maximum .
This document models and simulates the acceleration of a GM EV1 electric vehicle from 0 to 60 mph using MATLAB. It considers three mass scenarios: the base mass of 1560kg, a reduced mass of 1326kg, and an increased mass of 1794kg. The acceleration is modeled in two phases using differential equations. Simulation results show that acceleration decreases as mass increases, with times to reach 60 mph being 9.1, 7.8, and 10.5 seconds respectively. A mathematical solution to the differential equations is also derived and verified against MATLAB simulations, showing close matches.
This document provides Matlab code examples for modeling various receiver non-idealities including additive white Gaussian noise, carrier frequency offset, phase noise, I/Q imbalances, automatic gain control, sampling clock offset, and clipping and quantization. The code shows how to apply these non-idealities to an input signal in sequence to generate a simulated received signal. Parameters for each non-ideality can be configured and the code outputs both the processed signal and information about the non-ideality parameters.
1. Various common signals were generated using MATLAB, including unit impulse, unit step, ramp, sinc, sine, sawtooth, square, and triangular signals. Both continuous and discrete forms were produced.
2. Operations on the generated signals included plotting their amplitude over time or index, adding titles and labels to figures, and displaying the results in different subplot configurations for comparison.
3. Common periodic signals like sine and square waves were generated along with aperiodic signals such as ramp, impulse and step functions to demonstrate the creation of basic continuous and discrete time signals in MATLAB for analysis and simulation.
The document discusses equations for open channel flow and methods to calculate parameters for different channel cross section shapes including trapezoidal, circular, parabolic, and natural channels. It provides equations for area, perimeter, and their derivatives with respect to depth (y) for each cross section shape. Methods using the Newton-Raphson technique are presented to calculate the normal depth (y) given inputs of discharge (q), channel properties, slope and Manning's roughness coefficient. Outputs from the methods include normal depth, area, wetted perimeter, hydraulic radius, mean depth, mean velocity, energy, Froude number and more. Python code implementing the Newton-Raphson method for each cross section shape is also presented.
This document discusses phase lead and lag compensators for digital control systems. It covers:
1. Designing a discrete-time phase lead/lag compensator by mapping the z-plane to the w-plane using bilinear transformation.
2. Defining phase lead and lag compensators based on the positions of poles and zeros in the w-domain transfer function.
3. A design approach using frequency response methods to meet a phase margin specification by determining the parameters of a first-order digital phase lead or lag compensator.
4. Examples of designing phase lead and lag compensators for different plant transfer functions to meet specifications on phase margin and steady state error.
This document discusses different methods for discretizing a continuous time DC servo motor transfer function for use in digital control. It provides the transfer functions obtained when discretizing the motor model using various methods like zero order hold, impulse invariant mapping, Tustin's approximation, and zero pole matching at a sample time of 0.05 seconds. A plot compares the step responses of the closed loop system using these different discretization methods, showing they provide similar performance with small differences.
The document reads in edge data from a CSV file, calculates various graph properties like the number of edges and vertices. It then creates adjacency and incidence matrices to represent the graph. It calculates the graph's Laplacian and finds its null space to obtain a set of fundamental cycles representing the graph's loops. The edge flows in these fundamental cycles are output to a new CSV file.
This document contains MATLAB code for analyzing the time response (step response, impulse response, and ramp response) of various transfer functions and control systems. It includes examples of open-loop and closed-loop transfer functions, uses the step, impulse, and lsim functions to obtain responses, and plots the results. Exercises are provided to analyze transient and steady-state response characteristics for different systems.
Time Dependent and Independent operations (signal and systems)Omkar Rane
This document contains code to perform signal processing operations on audio signals. It loads two audio files, adds them together, and plots the result. It also performs time shifting on one signal by 100 samples and reflects another signal to produce its time-reversed version, plotting both. The code verifies time shifting and reflection operations analytically on audio signals.
This document describes solving a steady scalar transport equation using an ADI algorithm with upwind differencing of the convective terms. The problem involves convection and diffusion of a scalar quantity in a stagnation point flow. Boundary conditions are given. The algorithm is modified from Problem Set 2 to include upwind differencing. Grid independent solutions are obtained for diffusion parameters of 0.1 and 0.01. Iteration time and accuracy are analyzed for different grid sizes.
I need help understanding the Pan Tompkins algorythm, and Id also .pdfeyewatchsystems
I need help understanding the Pan Tompkins algorythm, and I\'d also like to know how to detect
QRS peaks of the ECG (with circles, for example). I\'m using the script in this website as a
guidance, but I have trouble understanding what it\'s doing. Perhaps there\'s a simpler way to do
it? http://cnx.org/contents/YR1BUs9_@1/QRS-Detection-Using-Pan-Tompki
Our teacher has otherwise explained to us FIR filters, and wants us to use them instead of the
low pass, high pass that are mentioned in the website and though I do understand how they work,
I don\'t really know which window is the best, or how many coefficients the filter needs. I\'ve
applying the cut-off frequencies 5-15 because I\'ve seen that\'s where the QRS peaks are
concentrated. Is there any way to improve this as well?
TB=1;
TBn=TB/Fs;
N2=ceil(3.3/TBn);
Fc1 =5;
Fc2 =15 ;
wc1 = 2*pi*Fc1;
wc2 = 2*pi*Fc2;
wcn1 = 2*pi*Fc1/Fs;
wcn2 = 2*pi*Fc2/Fs;
Bz=fir1(N2,[wcn1 wcn2]);
y3=filter(Bz,1,x1);
figure; plot(x1); figure; plot(y3);
Solution
Save the function and use it as given below ::
pan_tompkin(ECG1,200,1) 1st is ECG raw data , 2nd is sampling frequency, 3rd is
for plots -always set it to 1
Matlab Code ------------------------------------ function .
function [qrs_amp_raw,qrs_i_raw,delay]=pan_tompkin(ecg,fs,gr)
%% function [qrs_amp_raw,qrs_i_raw,delay]=pan_tompkin(ecg,fs)
% Complete implementation of Pan-Tompkins algorithm
%% Inputs
% ecg : raw ecg vector signal 1d signal
% fs : sampling frequency e.g. 200Hz, 400Hz and etc
% gr : flag to plot or not plot (set it 1 to have a plot or set it zero not
% to see any plots
%% Outputs
% qrs_amp_raw : amplitude of R waves amplitudes
% qrs_i_raw : index of R waves
% delay : number of samples which the signal is delayed due to the
% filtering
if ~isvector(ecg)
error(\'ecg must be a row or column vector\');
end
if nargin < 3
gr = 1; % on default the function always plots
end
ecg = ecg(:); % vectorize
%% Initialize
qrs_c =[]; %amplitude of R
qrs_i =[]; %index
SIG_LEV = 0;
nois_c =[];
nois_i =[];
delay = 0;
skip = 0; % becomes one when a T wave is detected
not_nois = 0; % it is not noise when not_nois = 1
selected_RR =[]; % Selected RR intervals
m_selected_RR = 0;
mean_RR = 0;
qrs_i_raw =[];
qrs_amp_raw=[];
ser_back = 0;
test_m = 0;
SIGL_buf = [];
NOISL_buf = [];
THRS_buf = [];
SIGL_buf1 = [];
NOISL_buf1 = [];
THRS_buf1 = [];
%% Plot differently based on filtering settings
if gr
if fs == 200
figure, ax(1)=subplot(321);plot(ecg);axis tight;title(\'Raw ECG Signal\');
else
figure, ax(1)=subplot(3,2,[1 2]);plot(ecg);axis tight;title(\'Raw ECG Signal\');
end
end
%% Noise cancelation(Filtering) % Filters (Filter in between 5-15 Hz)
if fs == 200
%% Low Pass Filter H(z) = ((1 - z^(-6))^2)/(1 - z^(-1))^2
b = [1 0 0 0 0 0 -2 0 0 0 0 0 1];
a = [1 -2 1];
h_l = filter(b,a,[1 zeros(1,12)]);
ecg_l = conv (ecg ,h_l);
ecg_l = ecg_l/ max( abs(ecg_l));
delay = 6; %based on the paper
if gr
ax(2)=subplot(322);plot(ecg_l);axis tight;title(\'Low pass filtered\');
end
%% High Pas.
I need help understanding the Pan Tompkins algorythm, and Id also .pdf
Capsizing
1. Matlab Code for Solution of the Equation of Ship Rolling, CDF & LRFD
close all
clear all
clc
sigmahat=0.5;
significant_waveheight=0.10;
g=9.8;
A=8.1e-3*g;
B=3.11/(significant_waveheight^2);
t_start(1)=0;
t_end=900;
t_step=0.01;
number_t_step=(t_end-t_start(1))/t_step;
wave_omega_start(1)=0.05;
wave_omega_end=6;
wave_omega_step=0.05;
number_wave_omega_step=(wave_omega_end-wave_omega_start(1))/wave_omega_step;
for j=1:number_t_step+1
summation_wave_amplitude(j)=0;
end
%for i=1:number_wave_omega_step+1
%phase(i)=6.2832*rand(1,1);% Phase angle is not included in the following
for loop because
% the phase angle will be changed in each time
step
%end
load ('random_phase_for_irregularwave.mat')
for j=1:number_t_step+1
for i=1:number_wave_omega_step+1 % this loop will sum the wave amplitude
at each time step over all frequencies
%S(i)=A*wave_omega_start(i)^-5*exp(-B*wave_omega_start(i)^-4);
S(i)=0.0081*((g^2)/(wave_omega_start(i)^5))*exp(-
0.032*(g/(significant_waveheight*(wave_omega_start(i)^2)))^2);
zeta(i)=sqrt(2*S(i)*wave_omega_step);
wave_amplitude=zeta(i)*cos(wave_omega_start(i)*t_start(j)+phase(i));
summation_wave_amplitude(j)=summation_wave_amplitude(j)+wave_amplitude;
if(i<number_wave_omega_step+1) %if statement is used to eleminate the
121th element of wave_omega_start
wave_omega_start(i+1)=wave_omega_start(i)+wave_omega_step;
end
end
if(j<number_t_step+1)%if statement is used to eleminate the 40002th
element of wave_omega_start
t_start(j+1)=t_start(j)+t_step;
end
end
figure
plot(t_start,summation_wave_amplitude)
title('Time vs Irregular Wave Amplitude');
xlabel('Time in second');
ylabel('Amplitude in meter');
figure
histfit(summation_wave_amplitude);
2. title('Histogram for Irregular Wave');
xlabel('Wave Amplitude');
ylabel('Frequency');
figure
[muhat_1,sigmahat_1] = normfit(summation_wave_amplitude);
pdfNormal_1 = normpdf(summation_wave_amplitude,muhat_1,sigmahat_1);
plot(summation_wave_amplitude, pdfNormal_1)
title('PDF for Irregular Wave');
xlabel('Wave Amplitude');
ylabel('f(Wave Amplitude)');
figure
cdfNormal_1=normcdf(summation_wave_amplitude,muhat_1, sigmahat_1);
plot(summation_wave_amplitude,cdfNormal_1)
title('CDF for Irregular Wave');
xlabel('Wave Amplitude');
ylabel('F(Wave Amplitude)');
time_period_roll=6.3366;
natural_omega=(2*3.1416)/time_period_roll;
density=997.04;
beam=[6.50 6.58 6.75 6.84 7.01 6.92 6.67 6.64 5.23 2.70];
draft=3.81;
displacement=227984;
metacentric_height=.947;
moment_of_inertia=(displacement*metacentric_height)/natural_omega^2;
damping_coefficient_1=0.01107;
damping_coefficient_2=0.01186;
%b_1=damping_coefficient_1/moment_of_inertia;
%b_2=damping_coefficient_2/moment_of_inertia;
b_1=0.14639;
b_2=0.14639;
for j=1:number_t_step+1% for each time step initially the summation of
heeling moment is considered 0
summation_heeling_moment(j)=0;
end
for i=1:number_wave_omega_step+1% This loop will calculte the coefficient of
right hand side/heeling moment at each frequency
time_period_wave(i)=(2*3.1416)/wave_omega_start(i);
wave_length(i)=(g/(2*3.1416))*time_period_wave(i)^2;
for j=1:number_t_step+1% this loop generates the wave amplitude at each
frequency over the defined time period.
wave_apmlitude(j)=zeta(i)*cos(wave_omega_start(i)*t_start(j)+phase(i));
end
wave_height(i)=max(wave_apmlitude)- min(wave_apmlitude);% wave height is
calculted for the wave of each frequency by subtracting minimum amplitude
from maximum amplitude
%reduction_coefficient_wave_slope(i)=atan(wave_height(i)/wave_length(i));
reduction_coefficient_wave_slope=0.682;
if (time_period_wave(i)>=11.2)
coeff_roll_add_mass=(((time_period_wave(i)-11.2)*.015)/2.7)+.07;
else
coeff_roll_add_mass=0.07-(((11.2-time_period_wave(i))*.015)/2.7);
end
%simpson rule
delata_l=1;
b44=(delata_l/3)*coeff_roll_add_mass*density*draft*beam.^3;
3. added_mass_moment(i)=b44(1)+b44(2)+b44(3)+b44(4)+b44(5)+b44(6)+b44(7)+b44(8)+
b44(9)+b44(10);
amplitude_e(i)=0.5*reduction_coefficient_wave_slope*(wave_height(i)/g)*wave_o
mega_start(i)^2*(abs(natural_omega^2-
(wave_omega_start(i)^2*added_mass_moment(i))/moment_of_inertia));
for j=1:number_t_step+1% this loop will sum the right hand side at each
frequency over the time period
heeling_moment=(1/(g*1000))*amplitude_e(i)*moment_of_inertia*cos(wave_omega_s
tart(i)*t_start(j)+phase(i));
summation_heeling_moment(j)=summation_heeling_moment(j)+heeling_moment;
end
end
figure
plot(t_start,summation_heeling_moment)
title('Time vs Heeling Moment');
xlabel('Time in second');
ylabel('Heeling Moment');
figure
histfit(summation_heeling_moment);
title('Histogram for Heeling Moment');
xlabel('Heeling Moment');
ylabel('Frequency');
figure
[muhat_2,sigmahat_2] = normfit(summation_heeling_moment);
muhat_2
sigmahat_2
pdfNormal_2 = normpdf(summation_heeling_moment,muhat_2,sigmahat_2);
plot(summation_heeling_moment, pdfNormal_2)
title('PDF for Heeling Moment');
xlabel('Heeling Moment');
ylabel('f(Heeling Moment)');
figure
cdfNormal_2=normcdf(summation_heeling_moment,muhat_2, sigmahat_2);
plot(summation_heeling_moment,cdfNormal_2)
title('CDF for Heeling Moment');
xlabel('Heeling Moment');
ylabel('F(Heeling Moment)');
f_1=inline('-b_1*v-b_2*v*abs(v)-natural_omega^2*x+summation_right_side');%
According to the runge kutta method the second order differential
%equation should be represented as :
%v_dot+b_1*v+b_2*v*abs(v)+natural_omega^2*x=summation_right_side
x_initial(1)=0;% initial roll angle is zero
v_initial(1)=0;% initial roll velocity is zero
for j=1:number_t_step+1% Right hand side is a function of time
summation_right_side_A(j)=0;%
summation_right_side_B(j)=0;
summation_right_side_C(j)=0;
end
% the following loop will sum the right hand side at first for each time
% step
for j=1:number_t_step+1
4. for i=1:number_wave_omega_step+1% this loop wiil sum the right hand side
for each time step over all frequencies
right_hand_side_A=amplitude_e(i)*cos(wave_omega_start(i)*t_start(j)+phase(i))
;% according to the runge kutta procedure only t_start(j) is used for right
hand side
summation_right_side_A(j)=summation_right_side_A(j)+right_hand_side_A;% right
hand side is summed for each time step which will be used in dv_1.
right_hand_side_B=amplitude_e(i)*cos(wave_omega_start(i)*(t_start(j)+t_step*0
.5)+phase(i));% according to the runge kutta procedure only
t_start(j)+t_step*0.5 is used for right hand side
summation_right_side_B(j)=summation_right_side_B(j)+right_hand_side_B;%right
hand side is summed for each time step which will be used in dv_2 & dv_3.
right_hand_side_C=amplitude_e(i)*cos(wave_omega_start(i)*(t_start(j)+t_step)+
phase(i));% according to the runge kutta procedure only t_start(j)+t_step is
used for right hand side
summation_right_side_C(j)=summation_right_side_C(j)+right_hand_side_C;%right
hand side is summed for each time step which will be used in dv_4.
end
end
for j=1:number_t_step+1
dx_1=t_step*v_initial(j);
dv_1=t_step*f_1(b_1,b_2,natural_omega,summation_right_side_A(j),v_initial(j),
x_initial(j));
dx_2=t_step*(v_initial(j)+(dv_1/2));
dv_2=t_step*f_1(b_1,b_2,natural_omega,summation_right_side_B(j),v_initial(j)+
0.5*dv_1,x_initial(j)+dx_1*0.5);
dx_3=t_step*(v_initial(j)+(dv_2/2));
dv_3=t_step*f_1(b_1,b_2,natural_omega,summation_right_side_B(j),v_initial(j)+
0.5*dv_2,x_initial(j)+dx_2*0.5);
dx_4=t_step*(v_initial(j)+(dv_3));
dv_4=t_step*f_1(b_1,b_2,natural_omega,summation_right_side_C(j),v_initial(j)+
dv_3,x_initial(j)+dx_3);
if(j<number_t_step+1)
x_initial(j+1)=x_initial(j)+(1/6)*(dx_1+2*dx_2+2*dx_3+dx_4);%
x_initial is the roll angle
v_initial(j+1)=v_initial(j)+(1/6)*(dv_1+2*dv_2+2*dv_3+dv_4);
end
end
for j=1:number_t_step+1
x_initial_1(j)=x_initial(j)*57.2975;
end
figure
plot(t_start,x_initial_1)
title('Time vs Roll Angle');
xlabel('Time in second');
ylabel('Roll Angle in Degree');
figure
5. histfit(x_initial_1);
title('Histogram for Roll Angle');
xlabel('Roll Angle');
ylabel('Frequency');
figure
[muhat_3,sigmahat_3] = normfit(x_initial_1);
pdfNormal_3 = normpdf(x_initial_1,muhat_3,sigmahat_3);
plot(x_initial_1, pdfNormal_3)
title('PDF for Roll Angle');
xlabel('Roll Angle');
ylabel('f(Roll Angle)');
figure
cdfNormal_3=normcdf(x_initial_1,muhat_3, sigmahat_3);
plot(x_initial_1,cdfNormal_3)
title('CDF for Roll Angle');
xlabel('Roll Angle');
ylabel('F(Roll Angle)');
for j=1:number_t_step+1
righting_moment(j)=(1/1000)*displacement*metacentric_height*sin(x_initial(j))
;
end
figure
plot(t_start,righting_moment)
title('Time vs Righting Moment');
xlabel('Time in second');
ylabel('Righting Moment');
figure
histfit(righting_moment);
title('Histogram for Righting Moment');
xlabel('Righting Moment');
ylabel('Frequency');
figure
[muhat_4,sigmahat_4] = normfit(righting_moment);
muhat_4
sigmahat_4
pdfNormal_4 = normpdf(righting_moment,muhat_4,sigmahat_4);
plot(righting_moment, pdfNormal_4)
title('PDF for Righting Moment');
xlabel('Righting Moment');
ylabel('f(Righting Moment)');
figure
cdfNormal_4=normcdf(righting_moment,muhat_4, sigmahat_4);
plot(righting_moment,cdfNormal_4)
title('CDF for Righting Moment');
xlabel('Righting Moment');
ylabel('F(Righting Moment)');
%probability calculation
A=find(abs(righting_moment)<abs(summation_heeling_moment));
cases_rm_less_then_hm=length(A)
total_number_of_events=number_t_step+1
P_A=cases_rm_less_then_hm/total_number_of_events% probability that righting
moment is less then heeling moment
deck_immersion_angle=4.89;
B=find(abs(x_initial_1)>deck_immersion_angle);
cases_ra_greater_then_deack_angle=length(B)
P_B=cases_ra_greater_then_deack_angle/total_number_of_events
6. cases_for_A_and_B=0;
for j=1:number_t_step+1
if((abs(x_initial_1(j))>deck_immersion_angle) &&
(abs(righting_moment(j))<abs(summation_heeling_moment(j))))
cases_for_A_and_B=cases_for_A_and_B+1;
end
end
cases_for_A_and_B
P_C=cases_for_A_and_B/total_number_of_events
p=1;
q=500;
r(1)=1;
for m=1:160
l=1;
for n=p:q
segment_righting_moment_(m,l)=abs(righting_moment(n));
segment_heeling_moment_(m,l)=abs(summation_heeling_moment(n));
l=l+1;
end
[segment_muhat_4(m),segment_sigmahat_4(m)]=normfit(segment_righting_moment_(m
,1:500));
[segment_muhat_2(m),segment_sigmahat_2(m)]=normfit(segment_heeling_moment_(m,
1:500));
z(m)=(segment_muhat_4(m)-
segment_muhat_2(m))/sqrt(segment_sigmahat_4(m)*segment_sigmahat_4(m)+segment_
sigmahat_4(m)*segment_sigmahat_4(m));
p=p+500;
q=q+500;
if(m<160)%if statement is used to eleminate the 40002th element of
wave_omega_start
r(m+1)=r(m)+1;
end
end
figure
plot(r,z)
title('"Z" values for the each segment from the total 800 second window');
xlabel('Segment No');
ylabel('"Z"');
p_normal=normcdf(z);
figure
plot(r,p_normal)
title('probability for the each segment from the total 800 second window');
xlabel('Segment No');
ylabel('probability');
p=1;
q=40;
r1(1)=1;
for m=1:4
average_p_normal(m)=0;
for n=p:q
average_p_normal(m)=average_p_normal(m)+p_normal(n);
end
7. mean_p_normal(m)=average_p_normal(m)/40;
p=p+40;
q=q+40;
if(m<4)%if statement is used to eleminate the 40002th element of
wave_omega_start
r1(m+1)=r1(m)+1;
end
end
pp = polyfit(r1,mean_p_normal,3);
x1 = linspace(1,4);
y1_2 = polyval(pp,x1);
figure
plot(r1,mean_p_normal,'o')
hold on
plot(x1,y1_2)
hold off
save('average_p_normal.mat','y1_2','-append')
Matlab Code for the Comparison of Capsizing Probability for Different Sea State
close all
clear all
clc
load('average_p_normal.mat')
figure
plot(x1,y1_1,'k')
hold on
plot(x1,y1_2,'c')
hold on
plot(x1,y1_3,'b')
hold on
plot(x1,y1_4,'m')
hold on
plot(x1,y1_5,'g')
hold on
plot(x1,y1_6,'y')
hold on
plot(x1,y1_7,'r')
hold on
ylabel('Probaility of Capsizing')
xlabel('segment no')
legend('Sea Stae 1','Sea state 2','Sea state 3','Sea state 4','Sea state
5','Sea state 6','Sea state 7')
box off
a2 = axes('XAxisLocation', 'Top');
set(a2, 'color', 'none')
set(a2, 'YTick', [])
set(a2, 'XLim', [0 800])
xlabel(a2,'Time')