converting a variable in a table from cell to double

17 ビュー (過去 30 日間)
Salma fathi
Salma fathi 2022 年 10 月 18 日
コメント済み: Cris LaPierre 2022 年 10 月 19 日
I am trying to read some tables and concatenate them in one big table, but I am getting the following error
Cannot concatenate the table variable 'foE' because it is a cell in one table and a non-cell in another.
attached is the table "t1" that I am trying to read. the type of the variable in the other table is double, so how can I convert foE from cell to double
I am using the following lines to read the data
for kk = 1 : nfiles
fprintf('.......... File - %d of %d\n',kk, nfiles)
fullFileName = fullnames{kk};
t1 = readtable(fullFileName); %t1 stores the table from each file
if kk==1
Iono=t1;
else
Iono=[Iono; t1];
end
  4 件のコメント
Salma fathi
Salma fathi 2022 年 10 月 19 日
Thanks for your comment, i added the code that I am using to read the data.
Salma fathi
Salma fathi 2022 年 10 月 19 日
@Davide Masiello thank you for your comment, I tried cell2mat and got the following error
Brace indexing is not supported for variables of this type.
Error in cell2mat (line 42)
cellclass = class(c{1});
Error in Read_Split_Iono (line 32)
t1.foE = cell2mat(t1.foE);

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

回答 (1 件)

Cris LaPierre
Cris LaPierre 2022 年 10 月 18 日
Your variable is a cell because many of your values are '---'. Try this
t1.foE = str2double(t1.foE);
  2 件のコメント
Salma fathi
Salma fathi 2022 年 10 月 19 日
I did tried this before and got the folloing error
To assign to or create a variable in a table, the number of rows must match the height of the table.
Cris LaPierre
Cris LaPierre 2022 年 10 月 19 日
That is a separate error, and has more to do with what you are trying to do with the result than the conversion itself. Share the code that corresponds to that error message.

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

カテゴリ

Help Center および File ExchangeTables についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by