Can anyone help me in solving 3 eq for 2 variables in Matlab, I tried a lot using symbolic tool box but it gives me empty solution. The Matlab code works for 2 equation only. For three equation gives me empty solution.
The simplest explanation is that what Matlab is telling you is correct: there is no solution for the system of three equations.
One way to find out what's happening is to plot the solutions for the three equations individually. First take each equation and define the left side as a function in Matlab:
fun1 = @(phi, theta) cos(2*phi).^2 .* cos(2*theta) + sin(2*phi) .* cos(2*phi) .* sin(2*theta);
fun2 = @(phi, theta) sin(2*phi) .* cos(2*phi) .* cos(2*theta) + sin(2*phi).^2 .* sin(2*theta);
fun3 = @(phi, theta) -sin(2*phi) .* cos(2*theta) + cos(2*phi) .* sin(2*theta);
Now you can use ezplot(fun1)
to plot the solutions to the implicit function fun1(x,y)=0
. The solutions will be curves in the (theta, phi) plane. If you do this for fun2
and fun3
as well, the simultaneous solution will be represented by places where the curves from all three functions simultaneously intersect.
I don't know how to pile up three the three ezplot
plots on the same axes, but we can use contour
to accomplish the same thing:
x = linspace(-pi/2, pi/2, 180);
y = linspace(-pi/2, pi/2, 180);
[X, Y] = meshgrid(x, y);
contour(X, Y, fun1(X, Y), [0, 0], 'r', 'linewidth', 3);
hold all
contour(X, Y, fun2(X, Y), [0, 0], 'b');
contour(X, Y, fun3(X, Y), [0, 0], 'g');
hold off
legend('f_1(\theta,\phi)=0','f_2(\theta,\phi)=0','f_3(\theta,\phi)=0');
xlabel('\phi');
ylabel('\theta');
Which produces this graph:
We see that there are no points where the red, blue, and green curves (corresponding to solutions of fun1(x,y)=0
, fun2(x,y)=0
, and fun3(x,y)=0
, respectively) simultaneously intersect.
Thus your system of three equations has no solution.