Add lab session 9

Handed in on Jan 24.

Change-Id: I63f9a63a7ff9f5f0080d74d7ec8cd993c6fa4135
diff --git a/p9/graphs/coure.gnu b/p9/graphs/coure.gnu
new file mode 100755
index 0000000..7c2a3ff
--- /dev/null
+++ b/p9/graphs/coure.gnu
@@ -0,0 +1,31 @@
+#!/usr/bin/env gnuplot -c
+metall="coure"
+outputfile="../output/".metall
+datafolder="../data/".metall."/"
+
+# == CONFIGURACIÓ DE L'OUTPUT PEL LATEX ==
+set terminal cairolatex size 11cm, 8cm
+set output outputfile.'.tex'
+
+# == CONFIGURACIÓ DEL PLOT ==
+set xlabel '$t \, (\si{\second})$'
+set ylabel '$T \, (\si{\celsius})$'
+
+# Opcions per la llegenda:
+set key above
+set key spacing 1.5
+
+set xtics 1000
+
+plot datafolder.'10.dat' u 1:3:4 w yerr t '$x = \SI{10}{\centi\meter}$', \
+     datafolder.'20.dat' u 1:3:4 w yerr t '$x = \SI{20}{\centi\meter}$', \
+     datafolder.'30.dat' u 1:3:4 w yerr t '$x = \SI{30}{\centi\meter}$'
+
+# == CONFIGURACIÓ DE L'OUTPUT PER SVG ==
+# Això ho uso per generar també una imatge de previsualització que puc carregar
+# a l'ordinador per veure més o menys com a sortit el plot sense haver
+# d'inserir-ho al LaTeX per veure-ho.
+set terminal svg dashed size 600, 600 font "Computer Modern,Tinos,Helvetica,15"
+set output outputfile.'.svg'
+
+replot
diff --git a/p9/graphs/estacionari.gnu b/p9/graphs/estacionari.gnu
new file mode 100755
index 0000000..bb16ae2
--- /dev/null
+++ b/p9/graphs/estacionari.gnu
@@ -0,0 +1,70 @@
+#!/usr/bin/env gnuplot -c
+outputfile="../output/estacionari"
+datafolder="../data/estacionari/"
+
+tamb=20 #Celsius
+error_sist_b=1
+
+# == CONFIGURACIÓ DE L'OUTPUT PEL LATEX ==
+set terminal cairolatex size 11cm, 8cm
+set output outputfile.'.tex'
+
+# == CONFIGURACIÓ DEL PLOT ==
+set xlabel '$x \, (\si{\centi\meter})$'
+set ylabel '$\log((T - T_0) \, \si{\per\celsius})$'
+
+# Opcions per la llegenda:
+set key above
+set key spacing 1.5
+
+# == FIT ==
+set fit quiet
+
+# Funció per obtenir els dígits significatius d'una expressió
+f_sd(n, i) = (int(n) == 0 ? f_sd(n*10, i+1) : (int(n) == 1 ? i+1 : i))
+significant_digits(n) = f_sd(n - 10*int(n/10), 0)
+
+significant_digits_r(n) = (n == 1 ? 0 : significant_digits(1 - n))
+
+f(x) = a*x + b
+fit f(x) datafolder.'coure_fit.dat' u 1:(log(column(3) - tamb)) via a, b
+stats datafolder.'coure_fit.dat' u 1:2 name "STATSC" nooutput
+error_a = STATSC_slope_err
+sd_error_a = significant_digits(error_a)
+error_b = sqrt(STATSC_slope_err + error_sist_b)
+sd_error_b = significant_digits(error_b)
+rc = STATSC_correlation
+sd_rc = significant_digits_r(rc)
+title_f(a, b, rc) = sprintf('$\log (\Theta_C(x)) = %.'.sd_error_a.'f x + %.'.sd_error_b.'f$, $r = %.'.sd_rc.'f$', a, b, rc);
+
+g(x) = c*x + d
+fit g(x) datafolder.'ferro_fit.dat' u 1:(log(column(3) - tamb)) via c, d
+stats datafolder.'ferro_fit.dat' u 1:2 name "STATSF" nooutput
+error_c = STATSF_slope_err
+sd_error_c = significant_digits(error_c)
+error_d = sqrt(STATSF_slope_err + error_sist_b)
+sd_error_d = significant_digits(error_d)
+rf = STATSF_correlation
+sd_rf = significant_digits_r(rf)
+title_g(c, d, rf) = sprintf('$\log (\Theta_F(x)) = %.'.sd_error_c.'f x + %.'.sd_error_d.'f$, $r = %.'.sd_rf.'f$', c, d, rf);
+
+print(sprintf('delta(a) = %.'.sd_error_a.'f, sd=%.0f', error_a, sd_error_a))
+print(sprintf('delta(b) = %.'.sd_error_b.'f, sd=%.0f', error_b, sd_error_b))
+print(sprintf('delta(c) = %.'.sd_error_c.'f, sd=%.0f', error_c, sd_error_c))
+print(sprintf('delta(d) = %.'.sd_error_d.'f, sd=%.0f', error_d, sd_error_d))
+print(sprintf('rc = %.'.sd_rc.'f, sd=%.0f', rc, sd_rc))
+print(sprintf('rf = %.'.sd_rf.'f, sd=%.0f', rf, sd_rf))
+
+plot datafolder.'coure.dat' u 1:(log(column(3) - tamb)):(column(4)/(column(3) - tamb)) w yerr t 'Coure', \
+     datafolder.'ferro.dat' u 1:(log(column(3) - tamb)):(column(4)/(column(3) - tamb)) w yerr t 'Ferro', \
+     f(x) t title_f(a, b, rc), \
+     g(x) t title_g(c, d, rf)
+
+# == CONFIGURACIÓ DE L'OUTPUT PER SVG ==
+# Això ho uso per generar també una imatge de previsualització que puc carregar
+# a l'ordinador per veure més o menys com a sortit el plot sense haver
+# d'inserir-ho al LaTeX per veure-ho.
+set terminal svg dashed size 600, 600 font "Computer Modern,Tinos,Helvetica,15"
+set output outputfile.'.svg'
+
+replot
diff --git a/p9/graphs/ferro.gnu b/p9/graphs/ferro.gnu
new file mode 100755
index 0000000..c1fdc76
--- /dev/null
+++ b/p9/graphs/ferro.gnu
@@ -0,0 +1,30 @@
+#!/usr/bin/env gnuplot -c
+metall="ferro"
+outputfile="../output/".metall
+datafolder="../data/".metall."/"
+
+# == CONFIGURACIÓ DE L'OUTPUT PEL LATEX ==
+set terminal cairolatex size 11cm, 8cm
+set output outputfile.'.tex'
+
+# == CONFIGURACIÓ DEL PLOT ==
+set xlabel '$t \, (\si{\second})$'
+set ylabel '$T \, (\si{\celsius})$'
+
+# Opcions per la llegenda:
+set key above
+set key spacing 1.5
+
+set xtics 1000
+
+plot datafolder.'10.dat' u 1:3:4 w yerr t '$x = \SI{10}{\centi\meter}$', \
+     datafolder.'20.dat' u 1:3:4 w yerr t '$x = \SI{20}{\centi\meter}$'
+
+# == CONFIGURACIÓ DE L'OUTPUT PER SVG ==
+# Això ho uso per generar també una imatge de previsualització que puc carregar
+# a l'ordinador per veure més o menys com a sortit el plot sense haver
+# d'inserir-ho al LaTeX per veure-ho.
+set terminal svg dashed size 600, 600 font "Computer Modern,Tinos,Helvetica,15"
+set output outputfile.'.svg'
+
+replot
diff --git a/p9/graphs/generateGraphs.bash b/p9/graphs/generateGraphs.bash
new file mode 100644
index 0000000..89033d9
--- /dev/null
+++ b/p9/graphs/generateGraphs.bash
@@ -0,0 +1,5 @@
+#!/bin/bash
+mkdir -p ../output
+./coure.gnu
+./ferro.gnu
+./estacionari.gnu