I am extremely sorry about my previous code it was not giving correct result. But this code is working correctly.
function eq3variable(aaa1,bbb1,ddd1,ccc1,aaa2,bbb2,ddd2,ccc2,aaa3,bbb3,ddd3,ccc3)
var1=[aaa1,bbb1,ddd1,ccc1]
var2=[aaa2,bbb2,ddd2,ccc2]
var3=[aaa3,bbb3,ddd3,ccc3]
%solving equation
%reassigning values to convert equation into two variable = eliminating d1 and d2
aa1=aaa1*ddd2;
bb1=bbb1*ddd2;
cc1=ccc1*ddd2;
dd1=ddd1*ddd2;
aa2=aaa2*ddd1;
bb2=bbb2*ddd1;
cc2=ccc2*ddd1;
dd2=ddd2*ddd1;
%Subtracting equation1 and equation2
PP1=aa1-aa2;
RR1=bb1-bb2;
SS1=dd1-dd2;
QQ1=cc1-cc2;
%----------------------------------------------------
aa3=aaa3*ddd2;
bb3=bbb3*ddd2;
cc3=ccc3*ddd2;
dd3=ddd3*ddd2;
aa2=aaa2*ddd3;
bb2=bbb2*ddd3;
cc2=ccc2*ddd3;
dd2=dd2*ddd3;
%Subtracting equation3 and equation2
PP2=aa3-aa2;
RR2=bb3-bb2;
SS2=dd3-dd2;
QQ2=cc3-cc2;
eq2variable(PP1,RR1,QQ1,PP2,RR2,QQ2)
function eq2variable(aa1,bb1,cc1,aa2,bb2,cc2)
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
x=x;
y=y;
z=(-(aaa1*x)-(bbb1*y)+ccc1)/ddd1
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