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
syms n t; | |
% Set d to the series, using symsum() | |
d=1+symsum(sin(n/2*t)*(sin(((n+2)*pi)/(2))*4/(pi^2*n^2)+(-1)^n*2/(n*pi)),n,1,100); | |
% Prep an x-axis | |
t=linspace(-10,10,1000); | |
% Evaluate the values accordingly | |
data=eval(d); | |
% And plot it | |
plot(t,data); |
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 [answer] = montecarlo() | |
N = 100000; | |
M = 0; | |
for i = 1:N | |
x = rand-0.5; | |
y = rand-0.5; | |
M = M + (sqrt((x^2+y^2)) < 0.5); | |
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 [m b] = linear_regression(X, Y) | |
n = length(Y); | |
EX = sum(X); | |
EY = sum(Y); | |
EX2 = sum(X.*X); | |
EXY = sum(X.*Y); | |
m = (n*EXY - EX*EY) / (n*EX2 - EX*EX); | |
b = (EY - m*EX) / n; | |
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 [ x,iter ] = gauss_seidel(A,b,itermax,toll,x0) | |
%ESERCIZIO_2_7_F1 Summary of this function goes here | |
% Detailed explanation goes here | |
% [ x,iter ] = gauss_seidel(A,b,itermax,toll,xo) | |
%input: | |
% A->matrice sistema lineare , | |
% b-> vettore termine noto, | |
% itermax -> numero massimo di iterazioni, | |
% toll-> tolleranza richiesta, | |
% x0 -> vettore soluzione iniziale |
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 b64 = base64( str ) | |
%BASE64 Encode string (array of chars) into Base64 | |
% Currently seems to fail for any input > 4 characters. :( | |
%% Settings | |
% Valid output codes to choose from. | |
base64Chars = char([65:90, 97:122, 48:57, 43, 47]); % +/ per RFC 2045 et al. | |
%base64UrlChars = char([65:90, 97:122, 48:57, 45, 95]); % -_ per RFC 4648 §4 | |
base64PadChar = '='; |
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 [f, X, peaks, locs] = plotFFT( t, x, p ) | |
Fs = 1 / mean(abs(t(2:end) - t(1:end-1))); | |
%n = 2^nextpow2(length(x)); | |
n = length(x); | |
X = fft(x-mean(x), n) / length(x); | |
f = 0.5*Fs * linspace(0, 1, ceil(0.5*n+1)); | |
X = X(1:ceil(0.5*n+1)); | |
mX = abs(X); |
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
%% Trial FFT | |
% http://www.mathworks.co.uk/help/matlab/math/fast-fourier-transform-fft.html | |
fs = 48000; % Sample Rate | |
n = 4096; % Power of 2 number of samples/ length of FFT | |
% Get/Generate data | |
t = 0:1/fs:10-1/fs; % 10 sec sample | |
x = (1.3)*sin(2*pi*15*t) ... % 15 Hz component | |
+ (1.7)*sin(2*pi*40*(t-2)) ... % 40 Hz component |
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
% This scipt loads and plots data from a .mat file | |
clc | |
gxFdata = 0; | |
gyFdata = 0; | |
gzFdata = 0; | |
% Loads samples from file | |
dat = load('GyroSamples.mat'); | |
dat = load('samples.mat'); |
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
names = {} | |
x = hist(Lifetimes,[50 100 150 200 250 300 350 400]) | |
for i = 1:size(x) | |
x(:,i) = x(:,i)./sum(x(:,i)) | |
end | |
hist(Lifetimes,[50 100 150 200 250 300 350 400]) | |
legend(names) | |
bins = [50 100 150 200 250 300 350 400]; | |
figure() |
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
[Stanford Machine Learning](https://www.class-central.com/mooc/835/coursera-machine-learning) | |
[Functional Programming in Scala](https://www.class-central.com/mooc/422/coursera-functional-programming-principles-in-scala) | |
[MIT Analytics Edge](https://www.class-central.com/mooc/1623/edx-15-071x-the-analytics-edge) | |
[Principles of Reactive Programming](https://www.class-central.com/mooc/1186/coursera-principles-of-reactive-programming) | |
[Stanford Algorithms Part 1](https://www.class-central.com/mooc/374/coursera-algorithms-design-and-analysis-part-1) |