read matrix from .txt
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
0 投票
hello, can anyone tell me what do i have to do to read this matrix saved on a.txt file?
1 2 3 4
5 6 7 8
9 10 11 12
thx :)
採用された回答
Azzi Abdelmalek
2013 年 10 月 20 日
M=dlmread('filename.txt')
12 件のコメント
hi azzi! thx for the help! but is comining back this:
*>> M=dlmread('matlab1.txt')
Error using dlmread (line 139)
Mismatch between file and format string.
Trouble reading number from file (row 1u, field 1u) ==> ÿþ1*
Azzi Abdelmalek
2013 年 10 月 20 日
編集済み: Image Analyst
2013 年 10 月 20 日
From your post, your file contains a matrix of numbers, is it true? Maybe your file contains also characters.
lucas
2013 年 10 月 20 日
yes! i made that matrix on excel and save it to .txt
only contain this:
1 2 3 4
5 6 7 8
9 10 11 12
lucas
2013 年 10 月 20 日
the conversion of .xls to .txt maded by excel add other things? if i open it with the notepad i see the matrix of numbers that i wrote and nothing else
1 2 3 4
5 6 7 8
9 10 11 12
Azzi Abdelmalek
2013 年 10 月 20 日
You can import your data from your Excell file with xlsread. If your txt file contains only numbers, the code should work.
lucas
2013 年 10 月 20 日
but my homework asked me to read .txt haha :(
Image Analyst
2013 年 10 月 20 日
Alternatively, try importdata() or save from Excel as a CSV file instead.
Open your file with e.g. the notepad or MATLAB editor, and copy/paste the content here, using {}Code formatting.
Image Analyst
2013 年 10 月 20 日
Or better yet, just attach the whole file with the paperclip icon.
lucas
2013 年 10 月 20 日
thx man :)
Ok, there are special characters in your file, so the issue is probably the way you saved it with Excel. Try exporting the Excel file as CSV (Comma Separated Values) even if you name the file with a .txt extension.
lucas
2013 年 10 月 20 日
thx mate!! works fine now with that comma thing :)
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Spreadsheets についてさらに検索
タグ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
