我要在 LabView 中加入一個 Matlab script, 但是卻一直出現錯誤訊息 (error code 1050)
我確定我的 matlab 程式沒錯 (因為在 matlab 中執行正常)
在國外的網站上看到, 好像說 LabView 7.0 跟 Matlab R13 以後的版本好像有 communication 的問題. 但我matlab的版本是 R12 (V6.1), 搞不懂~被一個簡單的程式搞的快瘋了~~~
將我的 error message 及 VI 附加如下
我研究過你的程式了....感覺你好像只是想將一個*.txt中的數值資料讀出.....不是嗎?? 但是你的程式太繁複了....或許你想轉成matlab script需求的資料形式,但是若你將filepath轉成ascii碼後,又轉成float.....然後再使用load()函式,將造成資料型態不符合load這個函數的限定.....如果你只是想要將*.txt的檔案秀出來....我做了下面這個範例....提供你參考!!!

這個例子是將c:\play.txt中的數值,透過matlab load函式功能載入labview,並顯示出來....
程式:2004-10-25_140622_matlab_labview_文件載入範例.vi
txt檔(請放在c:\下):2004-10-25_140636_play.txt
真的希望能夠對你有幫助......(我的matlab是6.5版的!!!)
麟仔38285.5895486111謝謝你~我試過你的程式了,但結果還是一樣出現 error 1050. 我之前是直接在 input 端輸入字串 (檔案名), 但是不 work. 看國外的網站討論, 說是把字串轉成數值, 進入 matlab 後再轉回字串就行了, 但我照做以後還是不行~~會不會是我的版本有問題, 或者我安裝不完全呢?? PS. 我是要把*.txt 中的數值讀出, 在 matlab 中進行運算及繪圖. 謝謝!!
我的程式我試過都是正常的....所以我想可能是matlab版本的問題,或是labview與matlab的連結產生問題!!!
下面這段話,是在ni網站上找到的....
Problem: I have a VI that uses a MATLAB script node. The VI worked correctly when I had MATLAB 5.x or 6.0 installed on my computer. However, when I upgraded to MATLAB 6.1 (or 6.5), my VI stopped working and returned one of the following errors:
- "Error occurred while executing script. Error message from server: . in Untitled.vi"
- "Error 1047 occurred at Unable to connect to script server"
- "Error 1050, LabVIEW: The server failed to execute the script sent by LabVIEW. An error message has been received"
How can I fix this problem?
Solution: The ActiveX ID for MATLAB 6.1 and 6.5 (released after LabVIEW 6.0 was released) is different than in earlier versions. There is a patched matscript.dll, which fixes this problem. See KnowledgeBase 300A6NDT linked below for the patched DLL and instructions on how to apply this patch. The updated ActiveX ID's for MATLAB 6.1 are included with LabVIEW 6.1. For more information about the latest version of LabVIEW, please refer to the Upgrade Advisor link below.
Additionally, to run a script node, LabVIEW uses ActiveX technology to communicate with the script server engine that is installed with MATLAB. However, the ActiveX components of MATLAB, including the script server, are not registered with the operating system when MATLAB is first installed. They are registered the first time MATLAB is launched. Therefore, when using a MATLAB script node in LabVIEW make sure that MATLAB has been launched on that particular machine and its ActiveX components have been registered with the operating system. After following this procedure, LabVIEW should be able to run the MATLAB script nodes without error, regardless of what directory MATLAB has been installed into.
Apparently, there is also an alleged problem with the new MATLAB Web Server in MATLAB 6.5. If the web server is installed, LabVIEW can no longer connect to the MATLAB engine. Uninstalling the web server should fix this problem.
所以我懷疑你的matlab與labview的連結有問題,也就是matlab script的active x沒有指到正確的script sever engine(與matlab版本有關),還有,如果是lv7.0的話應該已經有支援matlab 6.1 or 6.5了,不能啟動可能與operating system也有關係....是不是試著反安裝matlab.....在安裝,然後再試labview(或反過來).....
下面這個網址連接到ni網站,是關於如何更新matlab script版本的(補釘!!!)
http://digital.ni.com/public.nsf/websearch/4475BC3CEB062C9586256D750058F14B?OpenDocument
你所轉貼的這一段文字我也看到了
也照著指示做過, 但依舊還是不行~~~
也重新安裝過了…
實在是百思不得其解…
還是不行的話.....我想你必須將你的問題mail給ni的工程師,或直接打電話給ni的工程師詢問看看.....
請問一下labview7.1有支援連結matlab6.5嗎,怎麼我lv7.1開matlab script也會出現error1047????
axn0122:
我記得我還沒有修正時 ,出現的error也是1047, 你先照著網頁中的步驟做吧