Skip to content

Instantly share code, notes, and snippets.

@yichao0319
yichao0319 / matlab:spectrogram
Last active April 1, 2022 16:37
matlab:spectrogram
%% Spectrogram takes the STFT of the signal
win = floor(Fs/32);
noverlap = floor(win/4); % 75% overlap
Nfft = Fs;
% P matrix contains the power spectral density of each segment of the STFT
[S,F,T,P] = spectrogram(data, win, noverlap, Nfft, Fs);
fh = figure(1); clf;
imagesc(T, F, real(S));
colorbar;
@yichao0319
yichao0319 / python:plot
Last active July 2, 2016 04:21
python:plot
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
# marker [ '+' | ',' | '.' | '1' | '2' | '3' | '4' ]
# linestyle or ls [ '-' | '--' | '-.' | ':' | 'steps' | ...]
fig_idx = 0
font_size = 10
@yichao0319
yichao0319 / python:new
Last active June 27, 2016 08:34
python:new
#!/usr/bin/env python
######################################
##
## Yi-Chao Chen @ UT Austin
##
## - Input
##
## - Output
##
@yichao0319
yichao0319 / matlab:opt
Created November 10, 2014 21:33
matlab:opt
%% get_dtw_opt: function description
function [arg1, arg2] = get_XX_opt(opt)
arg1 = 1;
arg2 = 2;
if nargin < 1, return; end
opts = regexp(opt, ',', 'split');
for this_opt = opts
eval([char(this_opt) ';']);
end
@yichao0319
yichao0319 / matlab:read and parse file
Last active August 29, 2015 14:07
matlab:read and parse file
data = textread(filename, '', 'commentstyle', 'shell', 'delimiter', ':');
@yichao0319
yichao0319 / gnuplot:legend
Created January 13, 2014 05:06
gnuplot:legend
reset
set terminal postscript eps enhanced 28
set size 1.2,0.09
set pointsize 0
set border 0
set noxtics;
set noytics;
set key Left above left reverse nobox horizontal spacing 1 samplen 3.5 width 2
@yichao0319
yichao0319 / matlab:plot
Last active April 4, 2022 14:42
matlab:plot
clf;
fh = figure;
fontSize = 28;
%colors = {'r', 'b', [0 0.8 0], 'm', [1 0.85 0], [0 0 0.47], [0.45 0.17 0.48], 'k'};
colors = {[228 26 28]/255, [55 126 184]/255, [77,175,74]/255, [152,78,163]/255, [255,127,0]/255, [255,255,51]/255, [166,86,40]/255, [247,129,191]/255, [153,153,153]/255};
lines = {'-', '--', '-.', ':'};
markers = {'+', 'o', '*', '.', 'x', 's', 'd', '^', '>', '<', 'p', 'h'};
%% line
@yichao0319
yichao0319 / gnuplot:bar
Last active January 25, 2016 03:37
gnuplot:bar
reset
set terminal postscript eps enhanced color 28
# set terminal postscript eps enhanced monochrome 28
# set terminal png enhanced 28 size 800,600
# set terminal jpeg enhanced font helvetica 28
set size ratio 0.7
data_dir = "DATA_DIR"
fig_dir = "FIG_DIR"
file_name = "FILE_NAME"
@yichao0319
yichao0319 / tshark:filter field
Created October 31, 2013 03:15
tshark:filter field
http://www.wireshark.org/docs/dfref/i/ip.html
tshark -r trace.pcap -R "ip.src == 28.222.232.44 && ip.dst == 69.171.224.14" -T fields -E separator=/t -e frame.number -e frame.time_epoch -e ip.src -e tcp.srcport -e ip.dst -e tcp.dstport -e tcp.options.timestamp.tsval -e http.user_agent
@yichao0319
yichao0319 / bash:escape sed
Created October 29, 2013 00:00
bash:escape sed
sed "s/XXX/$(echo ${replace} | sed -e 's/\\/\\\\/g' -e 's/\//\\\//g' -e 's/&/\\\&/g')/g" mother.file > output.file