Hello,

Try the following.

cp <- sapply(1:4, function(n) output0*exp(-0.3*TIME1[n]))
plot(TIME1, cp)


Hope this helps,

Rui Barradas
Em 17-12-2012 13:04, Andras Farkas escreveu:
> Dear All,
>   
> I was wondering if you could help me with the following:
> I have the code:
>   
> tin <-0.5
> tau <-24
> output0 <-10
> TIMELOW <-tin
> TIMEHIGH <-1*tau
> TIME1 <-c(seq(TIMELOW,TIMEHIGH, by = sign(TIMEHIGH-TIMELOW)*(tau-tin)/3))
>   
> then I would like to calculate:
>   
> cp1 <-output0*exp(-0.3*TIME1[1])
> cp2 <-output0*exp(-0.3*TIME1[2])
> cp3 <-output0*exp(-0.3*TIME1[3])
> cp4 <-output0*exp(-0.3*TIME1[4])
>   
> then
> plot(TIME1,c(cp1,cp2,cp3,cp4))
>   
> is there a way to rewrite the equations for calculating the cp(1 to n) in a 
> "single line" so that the run of the code will produce the vector  
> c(cp1,cp2,cp3,cp4)? At the end, I would like to have those values calculated 
> "at once" as opposed to using a new command line to incorporate the different 
> values for TIME1...
>   
> thanks,
>   
> Andras
>       [[alternative HTML version deleted]]
>
>
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to