fprintf function is not defined for 'sym' inputs error
8 views (last 30 days)
Show older comments
John Marck
on 17 Jul 2016
Commented: John Marck
on 17 Jul 2016
This came up on a homework assignment for my ENGR Dynamics class. I'm a distance student and I use Matlab 2016a on my local machine but I think the school uses a previous version. Anyway, my code ran fine locally but after sending the .m file to my TA, he got an error on these lines:
fprintf('v = %3.3f m/s',double(v))
fprintf('\ns = %3.2f m\n\n',double(s))
I did some digging and I made this change:
fprintf('v = %3.3f m/s',double(v))
fprintf('\ns = %3.2f m\n\n',double(s))
Again, this runs fine on my machine. Since I got full credit on the problem, and it's not a Matlab course, and the TA is pretty overworked as it is, I'm reluctant to ask him to keep debugging the issue. I was hoping somebody here could shed some light on this?
Side note, I'm new to Matlab. So if there's a better function to use, I'd love to learn it!
0 Comments
Accepted Answer
Walter Roberson
on 17 Jul 2016
As the Symbolic Expression improves, there are more expressions it can calculate directly. Between R2015b and R2016a there were improvements, so there are some calculations that would produce unevaluatable symbolic results before R2016a but can be evaluated in R2016a.
In particular, R2016a improved the handling of some expressions that deal with polynomials (including some cases where polynomials arise during computation that might not be obvious at the beginning of the problem.) When there are multiple roots, R2016a is now more likely to resolve all of the roots to numeric values where before it might just have returned a RootOf object.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!