I am extremely sorry about my previous code it was not giving correct result. But this code is working correctly.
var1=[aa1,bb1,cc1]
var2=[aa2,bb2,cc2]
%solving equation
%reassigning values to solve value of y
ay1=aa1*aa2;
by1=bb1*aa2;
cy1=cc1*aa2;
ay2=aa2*aa1;
by2=bb2*aa1;
cy2=cc2*aa1;
%Subtracting equation1 and equation2
P1=ay1-ay2;
R1=by1-by2;
Q1=cy1-cy2;
y=Q1/R1;
%reassigning values to solve value of x
ax1=aa1*bb2;
bx1=bb1*bb2;
cx1=cc1*bb2;
ax2=aa2*bb1;
bx2=bb2*bb1;
cx2=cc2*bb1;
%Subtracting equation1 and equation2
P2=ax1-ax2;
R2=bx1-bx2;
Q2=cx1-cx2;
x=Q2/P2;
x=x
y=y
end
For proper reading I had done some color changes:
Comments are written in green.
function and conditions are written in aqua blue.
Input arguments are highlighted by yellow color.
This code will not work if any of the input arguments is zero
No comments:
Post a Comment