istable() returns false for my table

I create a table under certain conditions, later want to check if it is a table yet.
Checking in the command window I get this
K>> (app.Results2Table)
ans =
Columns 1 through 5
643705 644260 644760 645000 0
646934 647489 647989 648229 0
650201 0 0 0 0
K>> istable(app.Results2Table)
ans =
logical
0
Looks like a table to me

 採用された回答

Les Beckham
Les Beckham 2025 年 7 月 15 日
移動済み: Walter Roberson 2025 年 7 月 15 日

0 投票

That is definitely not a table. You can confirm that with the whos command. Tables are formatted differently when displayed. Specifically, they have variable names (that look like column titles).

3 件のコメント

Les Beckham
Les Beckham 2025 年 7 月 15 日
移動済み: Walter Roberson 2025 年 7 月 15 日
For example:
T = array2table(rand(5))
T = 5×5 table
Var1 Var2 Var3 Var4 Var5 _______ _________ _______ _________ ________ 0.72169 0.44067 0.54442 0.51337 0.98782 0.36857 0.0020561 0.42387 0.19171 0.71103 0.60238 0.41035 0.83338 0.0030115 0.37504 0.57584 0.21747 0.86724 0.93166 0.15564 0.13459 0.56578 0.62416 0.53486 0.057996
Gavin
Gavin 2025 年 7 月 15 日
So it's not a table until I put the header on it even if I declare it as a table at the start. It's a matrix? I changed the check to ~isempty() and that works.
Thanks, that had me stumped.
Steven Lord
Steven Lord 2025 年 7 月 16 日
How exactly did you try to declare it as a table? What command did you use?
If you preallocated it to contain a certain amount of data like the following, that makes it an array (or since this is 2-dimensional, a matrix as per the definition used by the ismatrix function.) All table arrays are matrices, but it is not the case that all matrices or all arrays are tables.
a = zeros(5) % matrix and array, but not a table
a = 5×5
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Or if you did this, that makes it a cell array not a table.
b = {1, 2, 3, 4, 5}
b = 1×5 cell array
{[1]} {[2]} {[3]} {[4]} {[5]}

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

その他の回答 (0 件)

カテゴリ

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

製品

リリース

R2024b

タグ

質問済み:

2025 年 7 月 15 日

コメント済み:

2025 年 7 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by