如何读取R中的模拟输入? / 或者如何翻译现有的 Matlab 代码
我在响应时间实验中使用光电管对事件进行计时。它在 Matlab 中运行良好,但我想在 R 中控制它。你们中有人能帮我将 Matlab 代码翻译成 R 吗?
global AI ch0
AI = analoginput('nidaq', 1);
AI.InputType = 'SingleEnded';
ch0 = addchannel(AI,0);
谢谢!
I use a photoelectric cell to time an event in a response time experiment. 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以使用 R.matlab 包。这允许您在 R 中读取 MAT 文件,因此您可以简单地保存输入并在 R 中对其进行分析。或者,您可以直接在 Matlab 和 R 之间进行交互。我之前没有尝试过,但应该可以从 R 中调用 matlab 代码。提供的 CRAN 手册向您展示了如何操作。
http://cran.r-project.org/web/包/R.matlab/index.html
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
有一个程序叫windmill:
http://www.windmill.co.uk/index.html< /a>
(我认为仅限 Windows)与串行设备交互,您可能可以使用它将信息从设备获取到文件或管道,然后让 R 从那里读取。
您还可以在 rseek 或 R-help 档案中搜索“gps”,有几次人们发布了有关直接从 gps 设备读取位置信息到 R 的问题和答案,其中一些回复可能有效也适合你。
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 不支持与 DAQ 设备进行任何类型的直接交互(至少目前如此)。您唯一的选择是编写一些 C 代码来执行此操作并将其绑定到 R。
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.
写信给 National Instruments,要求他们为他们的 I/O 设备制作一个 R 包。 :)
Write National Instruments and ask them to make an R package for their I/O devices. :)