[chronojump] Fixing inertia momentum for machines with low oscillation



commit ec6fa0a61a4e2ce6a6fe8dff60f2d54b904d6f52
Author: Xavier de Blas <xaviblas gmail com>
Date:   Sat Feb 28 13:16:29 2015 +0100

    Fixing inertia momentum for machines with low oscillation

 encoder/inertia-momentum.R |   29 ++++++++++++++++++++++++-----
 1 files changed, 24 insertions(+), 5 deletions(-)
---
diff --git a/encoder/inertia-momentum.R b/encoder/inertia-momentum.R
index eb1eeea..f8dbb2f 100644
--- a/encoder/inertia-momentum.R
+++ b/encoder/inertia-momentum.R
@@ -54,21 +54,40 @@ calculate <- function (displacement, mass, length)
        #times where the maximums are found in milliseconds
        tmax <- rowMeans(ex$maxindex)
        print(c("tmax",tmax))
+       print(tmax)
+       
+       tmin <- rowMeans(ex$minindex)
+       print(c("tmin",tmin))
+
+       tall = sort(as.numeric(c(tmin, tmax)))
+       print("tall")
+       print(tall)
 
        #the last maximum is discarded
-       tmax <- tmax[1:(length(tmax)-1)]
-       print(c("tmax",tmax))
+       #tmax <- tmax[1:(length(tmax)-1)]
+       #print(c("tmax",tmax))
+       tall <- tall[1:(length(tall)-1)]
+       print(c("tall",tall))
 
        #Periods of the oscillations
-       T <- diff(tmax[1:length(tmax)])
+       T = NULL
+       #T <- diff(tmax[1:length(tmax)])
+       T <- 2 * diff(tall[1:length(tall)])
        print(c("T",T))
+       print("T is null")
+       print(is.null(T))
+       print(length(T))
+
+       print("logT i el Ilog")
+       print(log(T))
+       print(I(log(tall[1:(length(tall)-1)])))
 
        #Coefficients of a Logarithmic regression
-       logT <- lm( log(T) ~ I(log(tmax[1:(length(tmax)-1)])))
+       logT <- lm( log(T) ~ I(log(tall[1:(length(tall)-1)])))
        print(c("logT",logT))
 
        #The final period of the oscillation in seconds
-       finalT <- exp(logT$coefficients[1] + logT$coefficients[2]*log(tmax[length(tmax)]))/1000
+       finalT <- exp(logT$coefficients[1] + logT$coefficients[2]*log(tall[length(tall)]))/1000
        print(c("finalT",finalT))
 
        #Inertia momentum using the pendulus formula


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]