Skip to content

Instantly share code, notes, and snippets.

@unalfaruk
unalfaruk / velDoppSound.py
Created September 14, 2022 21:03
It's a simple python script that calculates the doppler shift from the velocity, and generates a sound wave for the observer...
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 9 13:43:13 2022
@author: faruk.unal
"""
import scipy.constants as sc
import numpy as np
from scipy import signal
@unalfaruk
unalfaruk / WEstOfConstant.py
Created July 8, 2022 16:52
Weighted Estimation of a Constant
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 23 21:45:31 2022
@author: personF
"""
import numpy as np
import matplotlib.pyplot as plt
class Resistor:
@unalfaruk
unalfaruk / ConstantEstimation.py
Created June 25, 2022 20:20
ESTIMATION OF A CONSTANT | A basic simulation code
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 23 21:45:31 2022
@author: personF
"""
import numpy as np
import matplotlib.pyplot as plt
class Resistor:
@unalfaruk
unalfaruk / main.c
Last active April 29, 2022 19:04
Convolution on ARM Processor
#include "stm32wlxx_hal.h"
#include "arm_math.h" // ARM::CMSIS:DSP
#define SIG_LENGTH 250
#define IMP_RSP_LEN 29
#define NUM_TAPS 29
#define BLOCK_SIZE 32
uint32_t freq; //it is just for trace.. not related to DSP
@unalfaruk
unalfaruk / interpolation_example.py
Created February 4, 2022 12:22
It is an example of "interpolation" in Python using NumPy.
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 4 15:20:49 2022
@author: unalf
"""
import numpy as np
import matplotlib.pyplot as plt
% Generating 4-level pulse amplitude modulation, quadrature amplitude modulation,
% and quadrature phase shift keying waveforms
% Define parameters
len = 10000; % Length of binary string
nvar = 0.15; % Noise variance
% Generate the random bit streams that have already been demultiplexed from
% a single high speed data stream
bin_str1 = round(rand(1,len)); % Inphase data stream
% Decoding QAM waveform using I/Q receiver
% Define parameters
N_samp = 1000; % Number of samples per symbol
N_symb = 10; % Number of symbols in transmission
cfreq = 1/10; % Carrier frequency of cosine and sine carriers
% Generate inphase and quadrature channels with 2-PAM waveforms
chI = 2*round(rand(1,N_symb))-1;
chQ = 2*round(rand(1,N_symb))-1;
% Define parameters
len = 100000; % Length of original binary data stream
N1 = 3; % First repetition factor; should be odd to avoid tie
N2 = 5; % Second repetition factor; should be odd to avoid tie
N3 = 7; % Third repetition factor; should be odd to avoid tie
% Generate binary data stream
bin_str = round(rand(1,len));
% Employ repetition code with repetition factors N1, N2, N3
% Define parameters
len = 10000; % Length of binary data stream
% Have two binary sources, one 50/50 and the other 90/10 in terms of ones
% and zeros
bin1 = round(rand(1,len)); % 50/50 binary
bin2 = round(0.5*rand(1,len)+0.45); %90/10 binary
% Encode strings of ones in terms of the length of these strings
enc_bin1 = [];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Sending binary data via sinusoidal signal manipulation
% Parameters
sig_len = 1000; % Signal length (in samples)
sampl_per_bin = 100; % Samples per binary representation
bin_data_len = sig_len/sampl_per_bin; %length of binary stream is a multiple of signal length
bin_data = round(rand(1,bin_data_len));
sig_carrier_base = sin(2*pi*(0:(1/sampl_per_bin):(1-(1/sampl_per_bin)))); % Baseline carrier