[R] Odp: Variable c and function c
Petr PIKAL
petr.pikal at precheza.cz
Tue Aug 21 17:49:34 CEST 2007
Hi
r-help-bounces at stat.math.ethz.ch napsal dne 21.08.2007 17:07:05:
>
> I have found the error in my script which was semi-automatically
translated
> from the other person's MATLAB code.
>
> The error is that c was assigned a value inside a function.
> That is the function body contained the following instructions
> c<-nw*czr
> d<-nw*cz
> rFren<-0.5*(abs((cz-c)/(cz+c))^2+abs((d-czr)/(d+czr))^2)
My guess is that rFren is computed with c defined above and
> firstguess<-c( 0,0,0,3,0.5, 0 , 0 , 0.000001)
firstguess is assigned above numbers
See
fff<-function(nw=10, czr=5, cz=3) {
c<-nw*czr
d<-nw*cz
rFren<-0.5*(abs((cz-c)/(cz+c))^2+abs((d-czr)/(d+czr))^2)
firstguess<-c( 0,0,0,3,0.5, 0 , 0 , 0.000001)
list(rFren, firstguess)
}
> fff()
[[1]]
[1] 0.6483025
[[2]]
[1] 0e+00 0e+00 0e+00 3e+00 5e-01 0e+00 0e+00 1e-06
> fff(1)
[[1]]
[1] 0.0625
[[2]]
[1] 0e+00 0e+00 0e+00 3e+00 5e-01 0e+00 0e+00 1e-06
Regards
Petr
>
> I have already run this function and obtained the results, it was rather
> long process, therefore I don't want to rerun it.
>
> I was not given any warnings.
> How did the interpreter treat this?
> Will the result change, if I change the variable from "c" to, say, "c."
?
> This variable is not used anywhere else in the function.
> --
> View this message in context:
http://www.nabble.com/Variable-c-and-function-c-
> tf4305781.html#a12256590
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
More information about the R-help
mailing list