楼主: jyliao
4481 2

Connecting MATLAB to R [推广有奖]

  • 0关注
  • 1粉丝

已卖:2648份资源

讲师

17%

还不是VIP/贵宾

-

威望
0
论坛币
2803 个
通用积分
9.3545
学术水平
8 点
热心指数
25 点
信用等级
5 点
经验
8305 点
帖子
238
精华
0
在线时间
562 小时
注册时间
2007-1-15
最后登录
2022-6-4

楼主
jyliao 发表于 2008-4-29 20:18:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

Connecting MATLAB to R

http://www.mathworks.com/matlabcentral/files/5051/content/Rdemo.html

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=5051&objectType=file#

209191.zip (127.41 KB) 本附件包括:
  • Rdemo.m
  • Contents.m
  • evalR.m
  • getRdata.m
  • openR.m
  • putRdata.m
  • closeR.m
  • Rdemo_01.png
  • Rdemo_02.png
  • Rdemo_03.png
  • Rdemo_04.png
  • Rdemo.png
  • Rdemo.html

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Connecting Connect MATLAB atlab matla MATLAB Connecting

已有 1 人评分经验 收起 理由
日新少年 + 60 补偿

总评分: 经验 + 60   查看全部评分

本帖被以下文库推荐

沙发
yahoocom 发表于 2009-3-18 21:22:00

Connecting MATLAB to R

The statistical programming language R has a COM interface. We can use this to execute R commands from within MATLAB. The connection requires a local installation of R and also of the R-(D)COM Interface (for Windows only). This can be downloaded from http://lib.stat.cmu.edu/R/CRAN/other-software.html or other CRAN mirror site.

Contents

Connect to an R Session

[status,msg] = openR; if status ~= 1 disp(['Problem connecting to R: ' msg]); end 

Run one of the R demos to test the connection.

evalR('demo("persp")'); 

Now copy the volcano data into MATLAB

volcano = getRdata('volcano'); 

Use SURF to plot the volcano

surf(volcano); axis off; view(-135,40); 

You can also copy the colormap from R

cols = char(evalR('terrain.colors(20)')); red = hex2dec(cols(:,[2 3])); green = hex2dec(cols(:,[4 5])); blue = hex2dec(cols(:,[6 7])); colormap([red,green,blue]/256); 

Another view

The R variable z has edges filled in for more realistic viewing. The surface is flipped around in the R version.

z = getRdata('z'); h = surf(fliplr(z)); axis off; view(-135,40); 

Add some lighting and turn off the edges

lightangle(-135,40); lighting gouraud set(h,'linestyle','none'); 

Now do some arithmetic in R. First push some data into R.

a = 1:10; putRdata('a',a) 

Run a simple R command

b = evalR('a^2') 
b = 1 4 9 16 25 36 49 64 81 100 

Run a series of commands and grab the result

evalR('b <- a^2'); evalR('c <- b + 1'); c = getRdata('c') 
c = 2 5 10 17 26 37 50 65 82 101 

Close the connection

closeR 

藤椅
lonestone 在职认证  发表于 2016-5-29 14:48:24
很好的东西江,

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-9 09:01