2014-01-22 60 views
0

我很難將矩陣導入Mathematica和Maple。該文件的格式如下:將矩陣導入Mathematica和Maple

 0.0000000 1.0000000 1.0000000 
    1.0000000 1.0000000 0.0000000 
    1.0000000 0.0000000 0.0000000 

當導入到與數學:

In[1]:= Import["Matrix1.txt", "Table"] 

    Out[1]:= {{0.0000000 1.0000000 1.0000000}, {1.0000000 1.0000000 0.0000000}, {1.0000000 0.0000000 0.0000000}} 

從那裏它不以數學函數響應。顯然看起來不正確的導入。

此外,在楓:

> A = ImportMatrix["Maple_Matrix1.txt", source=delimited] 
    > 
    > A 
    > syntax error, missing operator or ';': 

更多問題導入。

導入到任何一個都會很好。每個人都有一套我想使用的內置功能。

+0

在Mathematica中嘗試執行'FullForm [Import [「Matrix1.txt」,「Table」]]',我希望你會馬上看到問題。看起來好像我不熟悉的楓樹在同樣的問題上也是一團糟。 –

+0

FullForm []實際上把我帶出了mathematica shell ... –

回答

2

對於您顯示的純文本數據,以下任何內容至少應適用於Maple版本14至17。只有最後兩個將在Maple 13中工作。

請注意在函數調用中使用圓括號而不是方括號。

請注意分號(或冒號,以抑制打印結果作爲輸出)作爲語句終止符。這是1D Maple表示法輸入所需的。

ImportMatrix("Maple_Matrix1.txt", source=MATLAB, mode=ascii); 

ImportMatrix("Maple_Matrix1.txt", source=MATLAB, mode=ascii); 

ImportMatrix("Maple_Matrix1.txt", delimiter=" "); 

ImportMatrix("Maple_Matrix1.txt", source=delimited, delimiter=" "); 

還要注意的是,在華普的語法任務是:=,不=。後者只會創建一個方程式(並且本身並不分配任何東西)。所以你會想要,比如說,

A := ImportMatrix("Maple_Matrix1.txt", delimiter=" "); 
+0

美麗,謝謝。 –

0

你的矩陣看起來像它正在作爲一個字符串處理。嘗試在importHead [%[[1]]]之後運行,它可能會說它是一個字符串。如果它是一個列表,那麼Head [%[[1]] [[1]]]可能應該是真實的。 您的文件選項卡或空間分隔? 您可能需要嘗試ReadList [「FILE」,{Number,Number,Number}]