fprintf function is not defined for 'sym' inputs error

8 views (last 30 days)
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!

Accepted Answer

Walter Roberson
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.
  1 Comment
John Marck
John Marck on 17 Jul 2016
That makes a lot of sense. I was able to remotely log in to one of the school's engineering computers and test my revised code in R2015a and it worked. At least now I have access to the same version of Matlab that my instructor uses to test stuff in the future.
Would be nice if Matlab had a feature to test-run code in previous versions!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!