Skip to content

Instantly share code, notes, and snippets.

View rudra101's full-sized avatar

rudra101

View GitHub Profile
@rudra101
rudra101 / carrierAndEnvelopeWaves_v0.R
Created July 16, 2023 00:04
Simulates movement of superposition of two traveling waves through a media
library(ggplot2)
# sin(k1.x - w1.t) + sin(k2.x - w2.t) = 2 * carrier * envelope
# physics 8.03SC lecture from Prof Yen-Jie Lee
# lecture 13 - dispersive media, carrier waves and envelope
# IMPROVEMENT NEEDED - repeated ggplot call results in a strobing effect which is not present
# in Prof. Lee's simulations.
alpha = -0.9 # set alpha = 1 for envelope to move forward
k1 = 1
w1 = k1 * sqrt(1 + alpha*k1*k1)
k2 = 0.9
@rudra101
rudra101 / deepCopyDict.m
Created March 5, 2021 05:20
Deep copying a py.dict object in Matlab
% Author: Rudradeep Mukherjee. Date: 5th March, 2021, 10:30AM IST.
% implementation of deep copy of a python dict in Matlab for custom purpose.
% if edge case or bug detected, please let Rudradeep know.
function res = deepCopyDict(pydict)
res = py.dict(pyargs());
keys = pydict.keys();
for jj = 1:length(keys);
key = keys{jj};
val = pydict{key};