25 abr. 2014

Sum Spectra Simulation (R exercise)


This is a simple exercise:
 I have the spectrum of three different ingredients:  lactose, soya protein concentrate and wheat gluten. I want to simulate in R a mixture of these three ingredients in different concentrations, for example 30% lactose, 20% soya and 50% gluten.

lactose<-read.csv("lactose.csv",header=TRUE)
soya<-read.csv("soya_prot.csv",header=TRUE)
gluten<-read.csv("wheat_gluten.csv",header=TRUE)


matplot(wave.NIR,t(lactose),type="l",lty=1,xlab="nm",
+ ylab="log 1/R",col="blue",main="NIR Spectrum Lactose")
 

matplot(wave.NIR,t(soya),type="l",lty=1,xlab="nm",
+ ylab="log 1/R",col="blue",main="NIR Spectrum Soya")

matplot(wave.NIR,t(gluten),type="l",lty=1,xlab="nm",
+ ylab="log 1/R",col="blue",main="NIR Spectrum Lactose")
 
Now let´s calculate the percentage spectrum for each component of the mixture:
lactose_1<-0.3*lactose
soya_1<-0.2*soya
gluten_1<-0.5*gluten
 
Now we can add this percentage spectra:
Mixture<- lactose_1 + soya_1 + gluten_1
matplot(wave.NIR,t(Mixture),type="l",lty=1,xlab="nm",
+ ylab="log 1/R",col="blue",main="Mix Spectrum")
 
 
Each spectrum has been treated as a vector

No hay comentarios:

Publicar un comentario