MATLAB: How to use struct2cell with the argument of type sym

MATLABsturct2cell sym

Dear all,
When I try running the following code:
.....
syms tmpval;
for iev = 1:nendog;
vname = char(endocmat(iev));
vname0 = [vname,'_0'];
tmpstring = ['diff(Util,',vname0,')'];
lmss_string = tmpstring;
for jlag = 1:maxvleads(neqs-1,iv);
lmss_string = [lmss_string,' + ((1/nbeta__)^',num2str(jlag),')*(',tmpstring,')'];
end;
for jlead = 1:maxvlags(neqs-1,iv);
lmss_string = [lmss_string,' + (nbeta__^',num2str(jlead),')*(',tmpstring,')'];
end;
eval(['tmpval = sym(0) + ',lmss_string,';']);
lmss_coefdefs{icoefdef} = ['lmss_vec(',num2str(iev),') = ',char(struct2cell(tmpval)),';'];
end;
The error message displays on the command window;
??? Undefined function or method 'struct2cell' for input arguments of type 'sym'.
My matlab version is 2012(b). Although the code is not complete, it dosen't change the problem.
Thank you for your help.

Best Answer

Your R2008a system would be using the Maple-based symbolic toolbox. Your R2012b system would fairly likely be using the MuPAD based symbolic toolbox.
I do not recall that the Maple based toolbox produced structs, but I can't disprove it either. Or possibly for random reasons struct2cell() on Maple symbolic objects was defined to work even though they were not structs. In any case you should not be expecting a struct there.
I would suggest that your code should be rewritten. I think you could probably build up your symbolic values iteratively. It does not appear to me that you are using any variable names that are constructed in the loop: it looks like the loop is providing numeric exponents and subscripts ?
Related Question