MATLAB Answers

Error using table/vertcat

8 views (last 30 days)
Hi all,
I have been getting an error in the function 'vertcat'. It can be reproduced on my machine by the simple code:
a = array2table(['1', '1']);
b = array2table(['2', '2']);
[a;b]
The code above yields the error message:
Error using table/vertcat
Error: File: vertcat.m Line: 158 Column: 1
Illegal use of reserved keyword "catch".
Error in test (line 3)
[a;b]
Any idea what may be causing this and how to fix it? It appears to be a local error - if I run the same code on a different machine with the same version of MATLAB (2018b), it works fine. I initially thought that I accidently changed something in the vertcat function, but that appears not to be possible since I can't access the source code.
  1 Comment
Mathieu NOE
Mathieu NOE on 15 Oct 2020
hi
you should better describe what is the intention, data inputs and expected outputs
seems just you are not using this function for what it is intended for ... at least in the example

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 30 Oct 2020
Error: File: vertcat.m Line: 158 Column: 1
In R2018b, toolbox/matlab/datatypes/@tabular/vertcat.m does indeed have a catch at column 1 of line 158 . However, it is a valid catch
So, somehow, somewhere between line 17 of the file and line 158, your file has acquired an extra end statement.
You should probably reinstall MATLAB.
  1 Comment
Christoph Funke
Christoph Funke on 30 Oct 2020
Thanks! I reinstalled MATLAB and it works fine again.

Sign in to comment.

More Answers (1)

Manvi Goel
Manvi Goel on 30 Oct 2020
I tried reproducing it at my end and just like you mentioned, it works as expected and the arrays concatenate vertically. It might be a temporary issue that you're facing. Try restarting MATLAB and your local system.
In case this doesn’t work you can restore the default MATLAB search path with the following steps:
1. Take a backup of your 'pathdef.m' file, which can be located by using the command
>> which -all pathdef
Before proceeding, ensure that you make a safe copy of the file by copying it to a folder outside of your MATLAB path.
2. After taking the backup, execute the following commands in the MATLAB Command Window to restore the default MATLAB search path and rehash the toolbox cache:
>> restoredefaultpath
>> rehash toolboxcache
>> sl_refresh_customizations
After this step, please use MATLAB/ Simulink to see if the issue occurs again. If the issue is resolved, then you may want to save the new MATLAB search path by executing the following command:
>> savepath
NOTE: This will remove any custom paths you may have created. The following MATLAB Answers post is an additional resource on how to back them up:

Community Treasure Hunt

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

Start Hunting!

Translated by