solve command
4 views (last 30 days)
Show older comments
[x,y] = meshgrid(-3:1:3);
z = 1.5*x - 3;
mesh(x,y,z);
p = -1.5*pi;
q = -pi/2;
r = 0;
for i = 1:1:10
pause(0.1);
p = p + (0.0173*5);
q = q + (0.0173*5);
r = r + (0.0173*5);
a1 = 3*cos(p); b1 = 3*sin(p); c1 = -3;
a2 = 3*cos(q); b1 = 3*sin(q); c2 = -3;
a3 = 2*cos(r); b3 = 2*sin(r); c3 = 0;
syms a b c d
eq1 = 'a1*a + b1*b +c1*c -d =0';
eq2 = 'a2*a + b2*b + c2*c -d=0';
eq3 = 'a3*a + b3*b +c3*c -d =0';
[a,b,c] = solve(eq1,eq2,eq3,'a,b,c');
a = a/d;b = b/d; c = c/d;
disp(a);disp(b);disp(c);
z = -(a*x + b*y)/c;
mesh(x,y,z);
end
sir with the above code i am not able to get the interger value of a,b,c;the solution for this is
-(-b1*c2+b1*c3+b2*c1-b3*c1+b3*c2-b2*c3)/(-a1*b3*c2+a1*b2*c3+a3*b1*c2-b2*a3*c1+b3*a2*c1-a2*b1*c3)
(-a1*c2+a1*c3-a3*c1-a2*c3+a2*c1+a3*c2)/(-a1*b3*c2+a1*b2*c3+a3*b1*c2-b2*a3*c1+b3*a2*c1-a2*b1*c3)
(-b2*a3+a1*b2-a1*b3+b3*a2+a3*b1-a2*b1)/(-a1*b3*c2+a1*b2*c3+a3*b1*c2-b2*a3*c1+b3*a2*c1-a2*b1*c3)
so can anyone tell me how to access a1,b1,c1 in solve function.can use any other method for this thank you
0 Comments
Accepted Answer
Alexander
on 5 Jun 2012
Seems to be the same problem as here: http://www.mathworks.de/matlabcentral/answers/40281-substitution-after-differentiation-easy
Try this:
a = double(subs(a)); b = double(subs(b)); c = double(subs(c));
Like here:
[x,y] = meshgrid(-3:1:3);
z = 1.5*x - 3;
mesh(x,y,z);
p = -1.5*pi;
q = -pi/2;
r = 0;
for i = 1:1:10
pause(0.1);
p = p + (0.0173*5);
q = q + (0.0173*5);
r = r + (0.0173*5);
a1 = 3*cos(p); b1 = 3*sin(p); c1 = -3;
a2 = 3*cos(q); b2 = 3*sin(q); c2 = -3;
a3 = 2*cos(r); b3 = 2*sin(r); c3 = 0;
syms a b c d
eq1 = 'a1*a + b1*b +c1*c -d =0';
eq2 = 'a2*a + b2*b + c2*c -d=0';
eq3 = 'a3*a + b3*b +c3*c -d =0';
[a,b,c] = solve(eq1,eq2,eq3,'a,b,c');
a = a/d;b = b/d; c = c/d;
a = double(subs(a)); b = double(subs(b)); c = double(subs(c));
disp(a);disp(b);disp(c);
z = -(a*x + b*y)/c;
mesh(x,y,z);
end
Please note that I renamed one of your b1 to b2.
0 Comments
More Answers (1)
Andrei Bobrov
on 5 Jun 2012
[x,y] = meshgrid(-3:1:3);
pqr = reshape(bsxfun(@plus,[-1.5;-.5;0]*pi,(1:10)*0.0173*5),3,1,[]);
abc = cat(2,cos(pqr),sin(pqr),bsxfun(@times,[-1;-1;0]*3,ones(1,1,10)));
o3 = ones(3,1);
for jj = 1:size(abc,3)
b = abc(:,:,jj)\o3;
mesh(x,y,-(b(1)*x + b(2)*y)/b(3));
pause(0.5);
end
0 Comments
See Also
Categories
Find more on Assumptions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!