blob: 47cc204a22c4340da4484403497d9cd979f78f4e [file] [log] [blame]
Adrià Vilanova Martínez52e98432023-03-20 20:00:28 +01001library(tikzDevice)
2
3table <- read.table('../dades/dades.txt', sep="\t", header=TRUE)
4
5table$logI <- log(table$impulsosPerSegon)
6
7fit_lineal <- lm(logI~gruixMassic, data = table)
8summary(fit_lineal)
9
10fit_coef <- coef(fit_lineal)
11fit_coef
12
13plotall <- function() {
14 plot(table$gruixMassic, table$logI, pch = 4, xlab = "$t$ (g cm\\textsuperscript{-2})", ylab = "$\\log(I)$")
15 abline(fit_lineal, col = "mediumorchid2")
16 legend("topright", inset = c(0.015, 0.03),col = c("black", "mediumorchid2"), legend = c("Mesures", "Ajust"), pch=c(4, NA), lty=c(NA, 1))
17}
18
19plotallnormal <- function() {
20 plot(table$gruixMassic, table$impulsosPerSegon, pch = 4, xlab = "$t$ (g cm\\textsuperscript{-2})", ylab = "$I$ (\\#s \\textsuperscript{-1})")
21 curve(exp(fit_coef[1] + x*fit_coef[2]), col = "mediumorchid2", add = TRUE)
22 legend("topright", inset = c(0.015, 0.03),col = c("black", "mediumorchid2"), legend = c("Mesures", "Ajust"), pch=c(4, NA), lty=c(NA, 1))
23}
24
25pdf('grafica.pdf', width = 6, height = 5)
26plotall()
27dev.off()
28
29tikz("grafica.tex", width = 5.5, height = 4.5)
30plotall()
31dev.off()
32
33pdf('graficanormal.pdf', width = 6, height = 5)
34plotallnormal()
35dev.off()
36
37tikz("graficanormal.tex", width = 5.5, height = 4.5)
38plotallnormal()
39dev.off()