This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
par(mfrow = c(1, 3)) | |
# 3D plain scatterplot of the density, plot of the density and contour plot | |
scatterplot3d(u[,1], u[,2], pdf_, color="red", main="Density", xlab ="u1", ylab="u2", zlab="dCopula", pch=".") | |
persp(mycopula, dCopula, main ="Density") | |
contour(mycopula, dCopula, xlim = c(0, 1), ylim=c(0, 1), main = "Contour plot") | |
par(mfrow = c(1, 3)) | |
# 3D plain scatterplot of the CDF, plot of the CDF and contour plot | |
scatterplot3d(u[,1], u[,2], cdf, color="red", main="CDF", xlab = "u1", ylab="u2", zlab="pCopula",pch=".") | |
persp(mycopula, pCopula, main = "CDF") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
frank <- frankCopula(dim = 2, param = 3) | |
clayton <- claytonCopula(dim = 2, param = 1.2) | |
gumbel <- gumbelCopula(dim = 2, param = 1.5) | |
par(mfrow = c(1, 3)) | |
# Density plot | |
persp(frank, dCopula, main ="Frank copula density") | |
persp(clayton, dCopula, main ="Clayton copula density") | |
persp(gumbel, dCopula, main ="Gumbel copula density") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Closed loop transfer function with proportional regulator | |
k = 50; | |
R = k; | |
L = R*G; | |
F = L/(1+L); | |
step(F) | |
% Root locus (k > 0) | |
rlocus(G) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Step response | |
step(G) | |
% Impulse response | |
impulse(G) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% System response when u=sin(wt) and w=wc | |
w = 0.441; | |
H = G; | |
t = [0:0.01:500]; | |
u = sin(w*t); | |
[y t x] = lsim(H,u,t); | |
plot(t,y,'red') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Initialize Laplace domain variable | |
s = tf('s'); | |
% Transfer function | |
G = C*inv(s*eye(2)-A)*B+D; | |
% Bode diagram | |
bode(G) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%Mass attached to the spring (Kg) | |
m = 10; | |
% Friction coefficient | |
rho = 0.8; | |
% Spring constant (N/m) | |
k = 2; | |
% State space representation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Inductance (H) | |
l = 0.010; | |
% Capacitance (F) | |
c = 1*10^(-8); | |
% Resistance (Ohm) | |
r = 250; | |
% Generalized gain | |
m = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Capacitance | |
C = 10*10^(-6); | |
% Time constant | |
tau = R*C; | |
% Define the transfer function | |
sys = tf([1/R 0],[1 1/(R*C)]); | |
% Plot the frequency response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Load library mass and set seed | |
library(MASS) | |
set.seed(100) | |
# We are going to use 3 random variables | |
m <- 3 | |
# Number of samples to be drawn | |
n <- 2000 |