Cell array and double array

2 vues (au cours des 30 derniers jours)
Ana
Ana le 5 Juin 2021
Commenté : Ana le 7 Juin 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.

Réponses (1)

Atsushi Ueno
Atsushi Ueno le 5 Juin 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 commentaire
Ana
Ana le 7 Juin 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Import from MATLAB dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by