reading the contents of a text file

3 ビュー (過去 30 日間)
Deepa Maheshvare
Deepa Maheshvare 2020 年 11 月 7 日
回答済み: Star Strider 2020 年 11 月 7 日
I have the following content in a text file
1 2 3.45 4
2 2 3.43 4
3 2 3.23 4
4 2 3.46 4
5 2 3.345 4
6 2 3.4567 4
I'm trying to read the input in the following manner
m = 6
n = 4
fileid = fopen(f,'r');
content = fscanf(fileid,'%f', [m n]);
This doesn't return the above data as m x n .
May I know what's the right way to read this data?

採用された回答

Star Strider
Star Strider 2020 年 11 月 7 日
Since you have R2019b, use the readmatrix function. Another option is readtable if it has headers you want to preserve.
If it a simple file, load will likely also work.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Report Generator についてさらに検索

タグ

製品


リリース

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by