| library(tikzDevice) |
| |
| table <- read.table('../dades/bari_a.txt', sep="\t", dec=',', header=TRUE) |
| |
| fit <- nls(ImpulsesPerSecond ~ ni*exp(-t/tau), start = list(ni = 40, tau = 20), data = table) |
| summary(fit) |
| |
| tikz("bari.tex", width = 5.5, height = 3.5) |
| #pdf('pdf.pdf', width = 6, height = 4) |
| fit_coef <- coef(fit) |
| plot(table$t, table$ImpulsesPerSecond, pch = 4, xlab = "$t$ (s)", ylab = "$I$ (\\# s\\textsuperscript{-1})") |
| curve(fit_coef[1]*exp(-x/fit_coef[2]), col = "mediumorchid2", add = TRUE) |
| legend("topright", inset = c(0.015, 0.03),col = c("black", "mediumorchid2"), legend = c("Mesures", "Ajust"), pch=c(4, NA), lty=c(NA, 1)) |
| dev.off() |
| |
| table$logI <- log(table$ImpulsesPerSecond) |
| |
| tikz("bari_linealitzat.tex", width = 5.5, height = 3.5) |
| #pdf('pdf2.pdf', width = 6, height = 4) |
| fit_lineal <- lm(logI~t, data = table) |
| summary(fit_lineal) |
| plot(table$t, table$logI, pch = 4, xlab = "$t$ (s)", ylab = "$\\log(I)$") |
| abline(fit_lineal, col = "mediumorchid2") |
| legend("topright", inset = c(0.015, 0.03),col = c("black", "mediumorchid2"), legend = c("Mesures", "Ajust"), pch=c(4, NA), lty=c(NA, 1)) |
| dev.off() |