Cell array and double array

조회 수: 2 (최근 30일)
Ana
Ana 2021년 6월 5일
댓글: Ana 2021년 6월 7일
Hi, I have imported 40 Excel files into Matlab and I want to concatenate them vertically. I received this error message:
Error using tabular/cat (line 16)
Cannot concatenate the table variable 'MeanICNiActivation' because it is a cell in one table and a
non-cell in another.
16 t = vertcat(varargin{:});
I checked the files, and indeed as the error mentioned some files had columns with cell arrays while a majority of the files contain only double arrays. I have attached images (from Matlab) of parts of the data illustrating this matter i.e. one file with the cell array and another file with double array. I have highlighted the corresponding columns. In the Excel files, the rows with '' in the image (Matlab file) are blank.
My questions are:
  1. What could possibly cause this to occur i.e. some are classified as double while others as cell? Each file was processed the same way using the same script (I didn't write the script, it was given to me by my supervisor).
  2. What can I do to get around this issue so I can concatenate my files?
Many thanks.

답변 (1개)

Atsushi Ueno
Atsushi Ueno 2021년 6월 5일
I think your script file which is from your supervisor contains 'xlsread' function that is not recommended anymore.
num — Numeric data: matrix <---num = xlsread(filename,sheet,xlRange,'basic')
txt — Text data: cell array <---[num,txt,raw] = xlsread(___)
>What could possibly cause this to occur i.e. some are classified as double while others as cell? Each file was processed the same way using the same script (I didn't write the script, it was given to me by my supervisor).
Your script must contain two different use of xlsread functions. (See above)
>What can I do to get around this issue so I can concatenate my files?
You should check out the function 'xlsread' and 'readmatrix' for updating your Excel import functions.
Please excuse me if my guess is wrong.
  댓글 수: 1
Ana
Ana 2021년 6월 7일
Hello @Atsushi Ueno, thank you for your reply/ answer. That seems to make sense – my supervisor did mention something about an issue with the xlsread (in a different context). Though oddly enough there wasn't any 'xlsread' or 'readmatrix' functions in the script. I'll try to look into it further. Thank you again.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by