Clear Filters
Clear Filters

sym matrices get converted to struct

4 views (last 30 days)
Vaibhav Raghavan
Vaibhav Raghavan on 19 Aug 2017
Commented: Vaibhav Raghavan on 23 Aug 2017
I am working with symbolic expressions. After each computation, i save the resulting symbolic expression as an element in the matrix. Then I save these matrices in a .mat format, and load them later for use in another program. When I load it, the sym matrix gets automatically converted to struct class, and am unable to use this.
The warning reads,' Error occurred while trying to call loadobj on a sym object: Reference to non-existent field 's'. Class 'sym' is an unknown object class or does not have a valid 'loadobj' method. Object 'Uz43s' of this class is converted to struct'.
Here Uz43s was originally a symbolic matrix
The symbolic toolbox is installed properly. I am using MATLAB R2016a (version with Symbolic toolbox 7.0. I have also tried using higher versions of Matlab - R2017a with Symbolic math toolbox 7.2, and still receive this warning.

Answers (2)

Nate on 21 Aug 2017
Edited: Nate on 21 Aug 2017
Hi Vaibhav,
What functions are you using in order to save and load your symbolic expressions? I am attempting to replicate the issue, so more information about your code would be very helpful. This is my naive attempt:
x = sym('x');
y = sym('y');
matrix = [x y]
save( 'test.mat', 'matrix');
load( 'test.mat' );
This did not produce any errors, and it appears to reload the symbols successfully. Please let me know if you have more information.
Nate on 22 Aug 2017
Could you clarify the difference between copying the code through the hard drive vs running the code on the other computer? My understanding is that you are copying both the M file and the MAT file, and that the error only occurs when you move the MAT file from one computer to the other and then try to load it. Is that correct?
Vaibhav Raghavan
Vaibhav Raghavan on 23 Aug 2017
Yes, that is right. The error occurs when I run the files on any other computer.

Sign in to comment.

Steven Lord
Steven Lord on 21 Aug 2017
While the MATLAB session in which you created and saved the data has Symbolic Math Toolbox available, I suspect the MATLAB session in which you're trying to load the symbolic matrix does not have Symbolic Math Toolbox installed. Check with the ver function that this product is installed.
Walter Roberson
Walter Roberson on 21 Aug 2017
Please show the output of
which -all sym
on the system that the load fails on.
Vaibhav Raghavan
Vaibhav Raghavan on 22 Aug 2017
C:\Program Files\MATLAB\R2016a\toolbox\symbolic\symbolic\@sym\sym.m % sym constructor

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!