blob: 76b4fffa11460e4b7f81417a3498067a0b8ccf40 [file] [log] [blame]
Adrià Vilanova Martínez52e98432023-03-20 20:00:28 +01001library(tikzDevice)
2
3table <- read.table('../dades/bari_a.txt', sep="\t", dec=',', header=TRUE)
4
5fit <- nls(ImpulsesPerSecond ~ ni*exp(-t/tau), start = list(ni = 40, tau = 20), data = table)
6summary(fit)
7
8tikz("bari.tex", width = 5.5, height = 3.5)
9#pdf('pdf.pdf', width = 6, height = 4)
10fit_coef <- coef(fit)
11plot(table$t, table$ImpulsesPerSecond, pch = 4, xlab = "$t$ (s)", ylab = "$I$ (\\# s\\textsuperscript{-1})")
12curve(fit_coef[1]*exp(-x/fit_coef[2]), col = "mediumorchid2", add = TRUE)
13legend("topright", inset = c(0.015, 0.03),col = c("black", "mediumorchid2"), legend = c("Mesures", "Ajust"), pch=c(4, NA), lty=c(NA, 1))
14dev.off()
15
16table$logI <- log(table$ImpulsesPerSecond)
17
18tikz("bari_linealitzat.tex", width = 5.5, height = 3.5)
19#pdf('pdf2.pdf', width = 6, height = 4)
20fit_lineal <- lm(logI~t, data = table)
21summary(fit_lineal)
22plot(table$t, table$logI, pch = 4, xlab = "$t$ (s)", ylab = "$\\log(I)$")
23abline(fit_lineal, col = "mediumorchid2")
24legend("topright", inset = c(0.015, 0.03),col = c("black", "mediumorchid2"), legend = c("Mesures", "Ajust"), pch=c(4, NA), lty=c(NA, 1))
25dev.off()