Cell array and double array

3 views (last 30 days)
Ana
Ana on 5 Jun 2021
Commented: Ana on 7 Jun 2021
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.

Answers (1)

Atsushi Ueno
Atsushi Ueno on 5 Jun 2021
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 Comment
Ana
Ana on 7 Jun 2021
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.

Sign in to comment.

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!