This file contains hidden or 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="$1" | |
# https://stackoverflow.com/questions/1672580/get-number-of-pages-in-a-pdf-using-a-cmd-batch-file | |
# Uses pdfinfo to find general information, focusing on the number of pages from which only the number is extracted. | |
NPAGES=$(pdfinfo "$FILENAME" | grep Pages | sed 's/[^0-9]*//') | |
# https://root42.blogspot.com/2012/10/counting-color-pages-in-pdf-files.html | |
# Uses ghostscript to measure any deviation from black in the ink colour used on pages. | |
GHOSTOUT=$(gs -o - -sDEVICE=inkcov $FILENAME | grep -v "^ 0.00000 0.00000 0.00000" | grep "^ " | wc -l) |
This file contains hidden or 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
%%% Low Pass Circuit | |
% A computable RC circuit model using a recurrence relation derived from | |
% MNA, through to a transfer function which is then discretised using the | |
% symbolic math toolbox. | |
% Author: Ben Holmes | |
% Date: 2019/01/01 | |
% License: GPL v3 | |
clear; |
This file contains hidden or 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
Calculate full frame to cropped equivalent. First order approximations only. Designed as described by <a href="https://northrup.photo/gear-basics/camera-body-features/sensor-size-crop-factor/">Chelsea and Tony Northrup</a>. | |
<form name="cropCalculator" action="" method="get"> | |
<table> | |
<tr> | |
<td>Crop factor:</td> | |
<td><input type="text" name="cropFactor" value="1.53"></td> | |
</tr> | |
<tr> | |
<td>Direction:</td> |
This file contains hidden or 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 X = forceFFTSymmetry(X) | |
% forceFFTSymmetry A function to force conjugate symmetry on an FFT such that when an | |
% IFFT is performed the result is a real signal. | |
% The function has been written to replace MATLAB's ifft(X,'symmetric'), as this function | |
% is not compatible with MATLAB Coder. | |
% Licensed under Creative Commons Zero (CC0) so use freely. | |
XStartFlipped = fliplr(X(2:floor(end/2))); |
This file contains hidden or 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=$(basename $1) | |
directory=$(dirname $1) | |
gs \ | |
-sOutputFile="$directory/${fileName%.*}-grayscale.pdf" \ | |
-sDEVICE=pdfwrite \ | |
-sColorConversionStrategy=Gray \ | |
-dProcessColorModel=/DeviceGray \ | |
-dCompatibilityLevel=1.4 \ | |
-dAutoRotatePages=/None \ | |
-dNOPAUSE \ |
This file contains hidden or 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 [Xmag, Xarg] = fftdBV(x) | |
%FFTDBV Returns the FFT of a voltage signal (in volts) with the amplitude response units dBV. | |
% Number of samples | |
N = length(x); | |
% Scaling factor is sqrt(2) except for at DC when it is 1. | |
k = [1, ones(1,N-1)*sqrt(2)]; | |
% Calculate the scaled DFT. |
This file contains hidden or 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 [Ac,Bc,Cc,Dc] = cascadeSSM(A,B,C,D) | |
% CASCADESSM A function to cascade linear state-space matrices for the | |
% purpose of cascading filters etc. | |
% | |
% Author: Ben Holmes | |
% Date: 2018/05/20 | |
% License: GPL V3 | |
% | |
% This function is derived from the answer | |
% https://math.stackexchange.com/questions/2201067/cascade-of-state-space-models-for-linear-systems |
This file contains hidden or 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 string = engFormat(value, type) | |
%ENGFORMAT a function to take a passive electronic component value and | |
% return a string with the properly formatted suffix. | |
aVal = abs(value); | |
nn = 0; | |
if strcmp(type,'R') | |
type = char(937); | |
end |
This file contains hidden or 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 [transferFunction] = circuitShelf(isHighShelf,R,C,f) | |
%%% CircuitShelf: A circuit informed shelf filter written as a continuous | |
%%% time transfer function. | |
% Author: Ben Holmes | |
% Date: 2017/12/16 | |
% License: GPL v3 | |
% Arguments: | |
% - isHighShelf: Boolean variable to switch between highpass and lowpass | |
% - R: 2x1 vector of resistor values |
This file contains hidden or 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 [I, J] = bjt(v, Is, N, Bf, Br) | |
% BJT: a general model for the currents through a BJT and their | |
% derivatives. | |
% Ben Holmes, 2017/11/28, GPL 3.0 | |
% Arguments: | |
% - v: [vce; vbe], collector-emitter voltage and base-emitter voltage. | |
% - Is: saturation current | |
% - N: ideality factor | |
% - Bf: forward current gain | |
% - Br: reverse current gain |
NewerOlder