writetable command fails for any table in R2020b

A matlab script that has been running starting failing recently and I found the line that was failing was a writetable command. I looked at the table that was being written but the table looked fine to me. The error message when it failed was "Multiple strings and patterns given must have the same quantity". I made a small table (3x3) using the table command and then tried to use writetable and I got this same message so it seems to be happening for any table. I do not know what to do to resolve this.

3 Comments

@Michael Kerich: please show us the complete error message. This means all of the red text.
Also show us the output of this command:
which writetable -all
Such problems can happen, if you have modified Matlab's toolbox functions on purpose or accidentally. Are you working with admin privileges? Do you store user-defined functions on top of the path, where they can shadow built-in functions?
Michael Kerich's incorrectly posted "Answer" moved here:
Here is the information from the Matlab asked for:
>> tm = table ([1,2,3], [9,8,7],[20,21,22])
tm =
1×3 table
Var1 Var2 Var3
___________ ___________ ______________
1 2 3 9 8 7 20 21 22
>> writetable(tm, 'test')
Multiple strings and patterns given must have the same quantity.
>> which -all writetable
/usr/local/MATLAB/R2020b/toolbox/matlab/iofun/writetable.m
/usr/local/MATLAB/R2020b/toolbox/matlab/bigdata/@tall/writetable.m % tall method
As far as I know, this function is the same as it was when it was installed.

Sign in to comment.

Answers (1)

Use the debugger to find out the details. Let Matlab stop, when the problem occurs:
dbstop if caught error
Type this in the command window. Run the code again. When it stops, examine the reason by checking the locally used variables. What are the "multiple strings and patterns" the message is talking of?
Again: Do you store user-defined functions on top of the path, where they can shadow built-in functions?

6 Comments

There is no script to debug in the example I posted it is all at the command line. The writetable command fails immediately so I do not know what error I could catch. As for the error message, you see the table I made - I have no idea what multiple strings and patterns it is talking about. Also the which shows there is no other writetable commands in the path other than the ones from Matlab. No user defined scripts have been made with that name as far as I know.
I installed R2020b on another server and I created a table in that Matlab. When I tried to save it on this other server, I got the exact same error message so this issue has replicated on 2 different systems now.
Jan
Jan on 27 May 2022
Edited: Jan on 27 May 2022
"There is no script to debug in the example I posted it is all at the command line." - Nope. You have to debug the function writetable.
"The writetable command fails immediately" - as soon as you follow my instructions to enable the debugger, writetbale does not fail immediately, but stop, when the error occurs. The you have the chance to find the line which causes the error. I'm sure you find e.g. a command there, which calls a user-defined function, which shadows a built-in function. Therefore I've asked twice already, if you store user-defined functions on top of the path or if you append them securely to the end.
"No user defined scripts have been made with that name as far as I know." - This is not what I have asked for. The function writetable calls a large number of other Matlab functions. If one of these functions is shadowed by a user-defined function, such strange errors are expected.
If you install your software on another server and the problem is caused by your software, it is expected, that the same problem appears.
I use this tool to check for shadowed built-in functions: FEX: UniqueFuncNames
Sometimes it is frustrating, that I cannot simply type "dbstop if caught error" on your machine and let the code run. The debugging would take less than a second and it really easy. It takes much more time to type the instruction. But if you simply resist to follow my suggestion, I have no chance to help you.
So, well, good luck!
I am sorry if I was not clear, there are no user-defined functions on top of the path and none defined at the end of the path. I have search thru directories seeking any such things and I have found none. That is also why I went to another server which even if such things exist they would not exist on this server and I got the same error. I guess I can try the debugger on the writetable command itself which I did not know it would step into to check.
I tried the UniqueFuncNames and the debugger but neither gave a definitive answer to me. So I assumed you were correct and that some function was interfering with the writetable. I just started removing toolboxes from the PATH until the writetable started to work. So I did discover some kind of function conflict and by removing that toolbox from the path it started to work. So thanks for directing me to look for that.
Which toolbox turned out to be the problem?

Sign in to comment.

Categories

Products

Release

R2020b

Asked:

on 26 May 2022

Commented:

on 31 May 2022

Community Treasure Hunt

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

Start Hunting!