开发者

How read an analogue input in R? / or how to translate an existing Matlab code

开发者 https://www.devze.com 2023-01-17 08:07 出处:网络
I use a photoelectric cell to time an event in a response time e开发者_如何学Cxperiment. It works well in Matlab, but I wanted to control it in R. Would any of you be able to help me translate the Mat

I use a photoelectric cell to time an event in a response time e开发者_如何学Cxperiment. It works well in Matlab, but I wanted to control it in R. Would any of you be able to help me translate the Matlab code to R?

global AI ch0
AI = analoginput('nidaq', 1);
AI.InputType = 'SingleEnded';
ch0 = addchannel(AI,0);

Thanks!


You could play around with the R.matlab package. This allows you to read your MAT files in R, so you could simply save the input and analyse it in R. Alternatively, you could interact directly between Matlab and R. I didn't try it out before, but it should be possible to call the matlab code from within R. The provided manual on CRAN shows you how.

http://cran.r-project.org/web/packages/R.matlab/index.html


There is a program called windmill:

http://www.windmill.co.uk/index.html

(windows only I think) that interacts with serial devices, you could probably use that to get the information from your device to a file or pipe and then have R read from there.

You could also do a search for "gps" at rseek or in the R-help archives, there have been a few times that people have posted questions and answers about reading location information directly from gps devices into R, some of those replies may work for you as well.


R does not support any kind of direct interaction with DAQ devices (at least for now). The only option you have is to write some C code to do this and bind it to R.


Write National Instruments and ask them to make an R package for their I/O devices. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消