simple readtable() call throws error

Trying to run a one line script containing:
data = readtable("data.txt");
Where "data.txt" is in the same directory and contains:
0, 1
100, 2
200, 3
300, 4
400, 5
And I get the error:
Error using readtable
Dimensions of arrays being concatenated are not consistent.
Error in readtabletest (line 1)
data = readtable("data.txt");
What arrays are being concatenated??
I have tried changing the delimeter to spaces too

8 件のコメント

Dyuman Joshi
Dyuman Joshi 2023 年 6 月 27 日
Works fine for me here -
data = readtable("data.txt")
data = 5×2 table
Var1 Var2 ____ ____ 0 1 100 2 200 3 300 4 400 5
Can you upload your "data.txt" file so we can reproduce the error?
Brandyn Butchard
Brandyn Butchard 2023 年 6 月 27 日
here it is
Brandyn Butchard
Brandyn Butchard 2023 年 6 月 27 日
However, I have the error no matter what file I use
Hiro Yoshino
Hiro Yoshino 2023 年 6 月 28 日
It worked fine with me too.
What MATLAB version do you use?
Star Strider
Star Strider 2023 年 6 月 28 日
See Release in the right margin of this page.
Cris LaPierre
Cris LaPierre 2023 年 6 月 28 日
Pleaes share the result of the following code
which readtable -all
Brandyn Butchard
Brandyn Butchard 2023 年 6 月 28 日
which readtable -all
outputs:
E:\Program Files\MATLAB\R2022b\toolbox\matlab\iofun\readtable.m
Stephen23
Stephen23 2023 年 6 月 28 日
編集済み: Stephen23 2023 年 6 月 28 日
@Brandyn Butchard: please upload your actual data file and Mfile by clicking the paperclip button.

サインインしてコメントする。

回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023 年 6 月 28 日

0 投票

1st of all, verify and make sure that if you're calling the correct file. You may have two different files with the same name but different contents in two different directories
Here are four different ways to read data from data.txt:
D1 = readtable('data.txt')
D1 = 5×2 table
Var1 Var2 ____ ____ 0 1 100 2 200 3 300 4 400 5
D2 = readmatrix('data.txt')
D2 = 5×2
0 1 100 2 200 3 300 4 400 5
D3 = importdata('data.txt')
D3 = 5×2
0 1 100 2 200 3 300 4 400 5
D4 = dlmread('data.txt') % Not recommended
D4 = 5×2
0 1 100 2 200 3 300 4 400 5

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

製品

リリース

R2023a

タグ

質問済み:

2023 年 6 月 27 日

回答済み:

2023 年 6 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by