?? What data type are you expecting to get back from pyrunfile, such that you want to call vpa() on it and then call double() on the result of that?
vpa() is well defined for a few different input types:
- numeric (any of the built-in numeric classes), in which case entries are evaluated to symbolic floating point numbers
- logical, in which case entries are evaluated to symbolic floating point numbers 0.0 or 1.0
- symbolic
- symbolic function
- character vector or string scalar or string array, in which entries are numeric literals, in which case the entries are evaluated to symbolic floating point numbers
- character vector or string scalar or string array, in which entries are valid MATLAB variable names, in which case references to symbolic variable names are returned
- cell array whose entries are any of the above
None of these are double precision.
At this point, there are two logical possibilities:
- because of the previous initialization of x as double precision, that Simulink attempts to convert the symbolic or symfun result to double precision. If the input was representable as a symbolic floating point number that could potentially succeed, with double precision output; if the input was not representable as a symbolic floating point number then conversion would fail, leading to an error; or
- perhaps Simulink will just complain that the datatypes do not match, leading to an error
So the processing of the vpa() call is going to give an error if the input is invalid, or if it is considered a type mismatch, or if it could not be evaluated to symbolic floating point number; if it succeeds at all, the result would already be double precision, with there not needing to be any need to double() the result.
Can the result be symbolic? Well, the inputs to pythoncalltest are Simulink signals, and Simulink signals cannot be symbolic or symfun or character vector or cell array -- but in sufficiently new Simulink could potentally be string() entries.
If the results of pyrunonfile are numeric then it is a waste of time to call vpa() on them: just call double() directly. (Except you don't need to do that.)
If the results of pyrunonfile are string() then the x = pyrunfile will either give an error or will already convert them to double precision already.
So the vpa() and following double() can only cause problems, not solve any problems.