# Plotting the results of 3equation and 3 variables...

1 view (last 30 days)
farid p on 5 Jul 2021
Answered: VBBV on 6 Jul 2021
clc
clear all
close all
for x=1:1000:50000
syms Rab Rca Rbc
a = 1;
b = 5.45*(10^4);
y_gam11(x) = gamcdf(x,a,b);
y_gam1(x)=1-y_gam11(x);
a = 0.01*7.06;
b = 1.2*5.45*(10^4);
y_gam22(x) = gamcdf(x,a,b);
y_gam2(x)=1-y_gam22(x);
a = 0.075*7.06;
b = 1.5*5.45*(10^4);
y_gam33(x) = gamcdf(x,a,b);
y_gam3(x)=1-y_gam33(x);
gammaab(x)=y_gam1(x).*y_gam2(x);
gammabc(x)=y_gam2(x).*y_gam3(x);
gammaca(x)=y_gam3(x).*y_gam1(x);
eq1(x)=( 1-( (1-Rab)*(1-(Rca*Rbc)) ) )==gammaab(x);
eq2(x)=( 1-( (1-Rbc)*(1-(Rab*Rca)) ) )==gammabc(x);
eq3(x)=( 1-( (1-Rca)*(1-(Rab*Rbc)) ) )==gammaca(x);
sol=solve([eq1(x),eq2(x),eq3(x)], [Rab, Rbc, Rca]);
if Rab>0 && Rab<1
RabSol{x} = sol.Rab;
end
if Rbc>0 && Rbc<1
RbcSol{x} = sol.Rbc;
end
if Rca>0 && Rca<1
RcaSol{x} = sol.Rca;
end
end
plot(x,RabSol)
plot(x,RbcSol)
plot(x,RcaSol)
farid p on 5 Jul 2021
I am trying to solve the three equation-three variables involving a varibale (x) . Then I'm gonna store the results between 0 and 1 to plot them.
thx

VBBV on 6 Jul 2021
clc
clear all
close all
syms Rab Rca Rbc
%x = 1:100:500;
for x=1:100:500
a = 1;
b = 5.45*(10^4);
y_gam11(x) = gamcdf(x,a,b);
y_gam1(x)=1-y_gam11(x);
a = 0.01*7.06;
b = 1.2*5.45*(10^4);
y_gam22(x) = gamcdf(x,a,b);
y_gam2(x)=1-y_gam22(x);
a = 0.075*7.06;
b = 1.5*5.45*(10^4);
y_gam33(x) = gamcdf(x,a,b);
y_gam3(x)=1-y_gam33(x);
gammaab(x)=y_gam1(x).*y_gam2(x);
gammabc(x)=y_gam2(x).*y_gam3(x);
gammaca(x)=y_gam3(x).*y_gam1(x);
eq1(x)=( 1-( (1-Rab)*(1-(Rca*Rbc)) ) )==gammaab(x);
eq2(x)=( 1-( (1-Rbc)*(1-(Rab*Rca)) ) )==gammabc(x);
eq3(x)=( 1-( (1-Rca)*(1-(Rab*Rbc)) ) )==gammaca(x);
sol=vpasolve([eq1(x),eq2(x),eq3(x)], [Rab,Rbc,Rca]);
sol.Rab;
sol.Rbc;
sol.Rca
if sol.Rab>-1 & sol.Rab<3
RabSol(:,x) = sol.Rab;
end
if sol.Rbc>-1 & sol.Rbc<3
RbcSol(:,x) = sol.Rbc;
end
if sol.Rca>-1 & sol.Rca<3
RcaSol(:,x) = sol.Rca;
end
end
ans =
ans =
ans =
ans =
ans =
x = 1:100:500
x = 1×5
1 101 201 301 401
RabSol
RabSol =
RbcSol
RbcSol =
plot(x,(RabSol(:,1:100:500)),'linewidth',2); title('RabSol')
plot(x,(RbcSol(:,1:100:500)),'linewidth',2);title('RbcSol')
plot(x,(RcaSol(:,1:100:500)),'linewidth',2);title('RcaSol')