MATLAB: Getting numeric and symbolic coefficients of equation of a straight line in 2d or 3d

MATLABstaright line

Consider the general equation of a straight le in 3d a*x + b*y + c*z + d=0. I would like to get a vector giving [a,b,c,d] including those that are zero or infinity. a,b,c,d can be both numeric and symbolic

Best Answer

Try this
syms x y z
f = -9*x + 7*z + 9;
cd = subs(f, [x y z], [0 0 0]);
cx = subs(f, [x y z], [1 0 0])-cd;
cy = subs(f, [x y z], [0 1 0])-cd;
cz = subs(f, [x y z], [0 0 1])-cd;
cd = subs(f, [x y z], [0 0 0]);
c = [cx cy cz cd];