MATLAB: I am getting following error. “??? Error using ==> plot Conversion to double from sym is not possible.”

doubleplotsymbolic

clc
clear
syms x y
y = Dsolve('Dy = (x^3 - 5*y + 3*x)/x','x')
pretty(y)
% num2str(x)
xx = 1:.01:3;
yy = subs(y,x,xx)
plot(xx,yy)

Best Answer

You did not provide a boundary condition to dsolve(), so the result has an arbitrary constant of integration, probably named as 'C' followed by a positive integer. You cannot plot unless you change the constant to 0 or you provide a boundary condition to dsolve() so that the value of the constant is found.