看板 R_Language 關於我們 聯絡資訊
這是我的code 跟執行結果 > library(matlabr) > library(R.matlab) R.matlab v3.5.1 (2016-03-27) successfully loaded. See ?R.matlab for help. Attaching package: ‘R.matlab’ The following objects are masked from ‘package:base’: getOption, isOpen Warning message: package ‘R.matlab’ was built under R version 3.2.5 > Matlab$startServer() [1] 0 > matlab <- Matlab(host="localhost") > if (!open(matlab)) + throw("Matlab server is not running: waited 30 seconds.") > # Run Matlab expressions on the Matlab server > res <- evaluate(matlab, "A=1+2;", "B=ones(2,20);") > > # Get Matlab variables > data <- getVariable(matlab, c("A", "B")) #============================================================ Warning message: In readChar(con = con, nchars = nbrOfBytes) : 在非 UTF-8 MBCS 語區中只能以位元組為單位讀取 #============================================================ 重點就在這裡 這是什麼意思? 而且之後我的data還是有讀進去 所以不要理他? > cat("Recieved variables:\n") Recieved variables: > str(data) List of 2 $ A: num [1, 1] 3 $ B: num [1:2, 1:20] 1 1 1 1 1 1 1 1 1 1 ... - attr(*, "header")=List of 3 ..$ description: chr "MATLAB 5.0 MAT-file, Platform: PCWIN64, Created on: Tue Apr 19 14:27:16 2016 " ..$ version : chr "5" ..$ endian : chr "little" ===================================================================== 請問版上有R連結MATLAB的教學嗎?我爬文都蠻少的 還有一點就是 Matlab$startServer() 這行我執行第一次會出現一個MATLAB 但是我不能在這個MATLAB寫東西 我執行第二次才會有個畫面出來讓我在MATLAB做事 還是說我一次開R跟MATLAB 然後用R整理好的DATA 存起來 再叫MATLAB去做? ps:我要用matlab裡面的sgmm 經濟方面的Simulated Generalized Method of Moments http://www.yildiz.edu.tr/~tastan/SGMM.html 不知道有沒有大大做過 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.42.96.140 ※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1461047617.A.023.html
celestialgod: 練過一次就放棄,直接用system操作 04/20 19:34
f496328mm: system怎麼操作? 04/21 11:09
celestialgod: 用system command去組成呼叫matlab 04/21 11:22
celestialgod: 我是透過用rmatio轉存mat檔案 用system call去處理 04/21 11:22
celestialgod: mat檔案,這個就很難做到即時處理 04/21 11:23
celestialgod: 如果只是要某些模型結果,這樣做是滿方便的 04/21 11:23