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
# matches files/directories with patterns | |
# like NL300/L0.1, NL10/L0.4 etc | |
for i in NL*/L* | |
do | |
cd $i | |
echo $i | |
# do something else | |
cd .. | |
done |
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
% matches pattern NL300/L0.1 etc | |
% stores the result in a cell structure | |
dirList = glob("NL*/L*"); | |
% Loop through the elements of the cell | |
for i = 1:length(dirList) | |
dirname = dirList{i,1}; % pick out individual item |
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
function A = autocorr(x, NA) | |
% | |
% Given a vector "x", computes the autocorrelation function A = <x(t) x(0)>/<x(0) x(0)> | |
% | |
% If a second argument NA is specified, only the first NA elements of "A" are computed | |
% Otherwise, NA = N - 1 by default. | |
% | |
x = x - mean(x); % subtract mean from "x" | |
N = length(x); % size of "x" |
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
function [v blockVar blockMean] = blockAverage(datastream, maxBlockSize, isplot) | |
Nobs = length(datastream) % total number of observations in datastream | |
minBlockSize = 1; % min: 1 observation/block | |
if(nargin < 2) | |
maxBlockSize = floor(Nobs/4); % max: 4 blocs (otherwise can't calc variance) | |
end | |
if(nargin < 3) |
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
program foo | |
character(len=12) :: filename | |
integer :: i | |
i = 10 | |
write (filename, "(A4,i0.4,A4)") "file", i,".dat" | |
print*, trim(filename) |
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
filename = sprintf('file%04d.txt',i) % say i = 10 | |
f1 = fopen(filename, 'w') | |
% write stuff to the file, ex: fprintf(f1,"%d",25) | |
fclose(f1) |
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
% Generate Data | |
x = linspace(0,1); | |
f1 = x.^2; | |
f2 = x.^3; | |
% plot it | |
h = figure; | |
plot(x,f1, 'r-', 'LineWidth', 4); hold on; | |
plot(x,f2, 'b-', 'LineWidth', 4); hold off; |
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
! | |
! Program to test solution of cyclic tridiagonal matrix | |
! | |
program testCyclicTridiag | |
integer, parameter :: n=5 | |
integer :: i, j | |
double precision :: a(5), b(5), c(5), d(5), x(5) | |
! |
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
\documentclass[xcolor=dvipsnames]{beamer} | |
\usepackage{graphics, listings} | |
\definecolor{gray}{rgb}{0.85,0.85,0.85} | |
\lstset{frame=single, | |
basicstyle=\tiny,backgroundcolor=\color{gray}, | |
language=Octave, | |
keywordstyle=\color{blue}, | |
stringstyle=\color{BrickRed}, | |
commentstyle=\color{OliveGreen}} |
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
! | |
!-------------------------------------------------------------------------------------------------- | |
subroutine tridiag (a, b, c, r, u, n, code) | |
! Solves for a vector u of length n the tridiagonal linear set ! from numerical recipes | |
! m u = r, where a, b and c are the three main diagonals of matrix ! | |
! m(n,n), the other terms are 0. r is the right side vector. ! | |
!-------------------------------------------------------------------------------------------------- | |
integer, parameter :: nmax = 100 | |
integer, intent (in) :: n | |
double precision, intent (in) :: a (n), b (n), c (n), r (n) |
OlderNewer