'Unable to concatenate the table variables 'Var1' and 'Var2', because their types are cell and double.' why this error is showing?
조회 수: 9 (최근 30일)
이전 댓글 표시
clear all;
clc;
%read X sample
ix1 = readtable("x_sample_01.dat",'ReadVariableNames',false);
x1 = table2array(ix1);
댓글 수: 0
답변 (1개)
Walter Roberson
2023년 3월 18일
Your file contains a mix of text and numeric. What result are you expecting when you ask to convert it to a single array?
댓글 수: 6
Walter Roberson
2023년 8월 25일
The case where there are empty columns get converted to doubles and filled with NaN -- no problem with table2array()
headerlines = {'Var1', 'Var2'};
Var1 = cell(2,1);
Var2 = [11; 22];
top = headerlines;
bottom = [Var1, num2cell(Var2)];
C = [top; bottom]
writecell(C, 'temp_table.xlsx');
ix1 = readtable('temp_table.xlsx')
x1 = table2array(ix1)
writecell(C, 'temp_table.csv');
dbtype temp_table.csv
참고 항목
카테고리
Help Center 및 File Exchange에서 Text Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!