Skip to content

Instantly share code, notes, and snippets.

View cychitivav's full-sized avatar
🎯
Focusing

Cristian Chitiva cychitivav

🎯
Focusing
View GitHub Profile
@cychitivav
cychitivav / fdm.py
Last active December 25, 2022 01:27
This gist is the implementation of Frequency-Division Multiplexing (FDM) to three audios with the same length and frequency sample
import wave
from playsound import playsound
from matplotlib import pyplot as plt
import numpy as np
def save_audio(x, fs, name):
with wave.open(name, mode='wb') as wav:
wav.setnchannels(1) # Mono
@cychitivav
cychitivav / neuralNetwork.py
Created November 21, 2022 16:09
Implementation of a simple neural network with the backpropagation algorithm.
import numpy as np
# Activation function and its derivative (sigmoid)
def sigmoid(x):
return 1 / (1 + np.exp(-x))
def sigmoid_derivative(x):
return sigmoid(x) * (1 - sigmoid(x))
# Error function (Mean Squared Error) and its derivative
def MSE(yBar, y):
@cychitivav
cychitivav / segmentation.py
Last active September 23, 2022 11:25
A function to segment a binary image
import numpy as np
import matplotlib.pyplot as plt
import cv2
def segment(src=None):
img = cv2.copyMakeBorder(src, 1, 1, 1, 1, cv2.BORDER_REPLICATE)
tags = np.zeros(img.shape)
@cychitivav
cychitivav / RPR.md
Last active September 10, 2022 17:15
Inverse kinematics problem of a RPR robot

Robot RPR

  1. ¿Cuántas soluciones posibles de la cinemática inversa existen como máximo?

    Rta./ Debido a que la articulación 3 está regida por $L_3$ y la orientación de la herramienta, la posición de esta articulación es única. Por lo tanto, las cantidad de soluciones depende de ¿cuántas posiciones puede tomar la articulación 2 y la 1?. Ahora, suponiendo que no existen limites articulares ni restricciones de movimiento, existen dos posibles soluciones para la cinemática inversa, una con $q_3$ negativo y otra con $q_3$ positivo, como se muestra en la siguiente figura.

@cychitivav
cychitivav / convolution2D.py
Created September 1, 2022 19:39
Function to find the convolution of an image with a mask of size nxn (n odd)
import cv2
import numpy as np
import matplotlib.pyplot as plt
def convolution2D(Img, Mask):
inv_mask = Mask[::-1,::-1]
dim = Mask.shape
@cychitivav
cychitivav / sym2tf.m
Last active April 9, 2022 03:57
Function to convert a symbolic expression to a transfer function.
function sys = sym2tf(symf,ts)
%TF2SYM Converts symbolic function to transfer function
% sys = SYM2TF(symf) converts the symbolic function symf of class 'sym'
% to transfer function.
%
% sys = SYM2TF(...,ts) converts the symbolic function s of class 'sym'
% to discrete transfer function.
%
% See also TF, SYM.