Skip to content

Instantly share code, notes, and snippets.

View mattgaidica's full-sized avatar

Matt Gaidica, Ph.D. mattgaidica

View GitHub Profile
@mattgaidica
mattgaidica / InnovationHyptheses.m
Created May 29, 2024 11:27
Two models of innovation vs. funding.
% Parameters
num_points = 100;
noise_level = 0.25; % Adjust this value to control the amount of noise
% Generate x values
x_curve = linspace(0, 1, 1000); % Generate 1000 points between 0 and 1
y_curve = log(1 + 99 * x_curve) / log(100); % Compute y values for the curve
% Select 12 random points along the curve
indices = randperm(length(x_curve), num_points);
% Neodymium magnet parameters
radius_mm = 10; % Magnet radius in millimeters
thickness_mm = 3; % Magnet thickness in millimeters
M = 1.0; % Magnetization in A m (adjust this value)
% Conversion factor from Gauss to voltage change
gauss_to_voltage = 1.5 / 1000;
% Permeability of free space
mu0 = 4 * pi * 1e-7;
@mattgaidica
mattgaidica / index_snip.html
Last active May 26, 2023 20:36
Rotating text snippet
<div class="is-content-justification-center" style="text-align:center">
<p>Did you know? <span id="rotatingText"><a target="_blank" href="https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0094215">Your brain slow down at 24, but peaks for some cognitive skills at other ages</a>.</span></p>
</div>
<script>
var textArray = [
'<a target="_blank" href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2754571/">The human brain is the fattest organ in the body, consisting of at least 60% fat</a>.',
'<a target="_blank" href="https://pubmed.ncbi.nlm.nih.gov/20329590/">Your brain can generate about 20 watts of electrical power</a>.',
'<a target="_blank" href="https://www.frontiersin.org/articles/10.3389/fnmol.2018.00216/full">Your brain uses about 20% of your bodys total energy and oxygen intake</a>.',
'<a target="_blank" href="https://www.brainline.org/author/brian-greenwald/qa/can-brain-itself-feel-pain">Your brain is incapable of feeling pain</a>.',
% Hargens et al. (1985) Figure 2 Recreation
xs = 30:10:70;
fitxs = 0:100;
% backed out from plot
loadCenter = [49,40,33,20,10];
loadErrorUpper = [50.5,42.5,38,25,12.5];
tensionCenter = [50,57,66,78,85];
tensionErrorUpper = [55,59,70,83,88];
// CMSIS Math
#include "arm_math.h"
#include "arm_const_structs.h"
#define SIG_SAMPLES 1024
#define BLOCK_SIZE 32;
#include "SWAsignal.h"
static float32_t filtSignal[SIG_SAMPLES];
// FILTER
extern float32_t inputSignal[SIG_SAMPLES] = { 2.09186630161801,
2.17981806111224, 2.2458345331045, 2.20702098281261, 2.05451765784143,
1.85916546584311, 1.7767591356537, 1.79267779175089, 1.85004295412198,
1.82818508686074, 1.72760166685638, 1.54716102329878, 1.39328525785108,
1.37279362871747, 1.37225304331087, 1.31022305067551, 1.21566162283513,
1.24287644762541, 1.38510735478485, 1.60578710124569, 1.93459280511249,
2.26110788479076, 2.43559114351632, 2.44546630752519, 2.37477587905096,
2.14026122136909, 1.77405580991932, 1.36350765781611, 0.998258176086951,
0.77357268824843, 0.567933484496516, 0.384275954063506,
0.288059029461084, 0.311287985207322, 0.323805443624895,
% MATLAB Code
% Generated by MATLAB(R) 9.9 and Signal Processing Toolbox 8.5.
% Generated on: 14-Dec-2020 15:39:25
% Elliptic Lowpass filter designed using FDESIGN.LOWPASS.
% All frequency values are in Hz.
Fs = 250; % Sampling Frequency
Fpass = 3; % Passband Frequency
n = 1024;
Fs = 250;
t = linspace(0,(1/Fs)*n,n)';
x = zeros(n,1);
for Fc = [5,25]
x = x + sin(2*pi*Fc*t);
end
L = numel(t);
n = (2^nextpow2(L));
extern float32_t inputSignal[FFT_SAMPLES] = { 2, 1.80075512683121,
1.27637053325758, 0.618871900194794, 0.0656112591359919,
-0.191339455865792, -0.0783815301685531, 0.331835982653282,
0.848683105690253, 1.23703243919349, 1.30782963716736,
0.991081272267325, 0.363318387328728, -0.380984958988108,
-1.00311152015435, -1.31072642475088, -1.23075864316698,
-0.836658892316524, -0.319613844304356, 0.085256675713322,
0.18946595086915, -0.0761778607350844, -0.634629641347059,
-1.29170265140208, -1.81007298891733, -1.99987740193588,
-1.79123725544972, -1.26095670117884, -0.603178660320141,
// ... application includes here
// CMSIS Math includes
#include "arm_math.h"
#include "arm_const_structs.h"
// using a 1024 point signal
#define FFT_SAMPLES 1024
#define FFT_SAMPLES_HALF (FFT_SAMPLES / 2)