- #1
Liffner
- 2
- 0
Hi everyone, my code is a little rusty and a work in progress but I was wondering how I would go about producing arrays for the calculations performed in the while loop for the analyses so they can be plotted.
I have the following parameter input;
G0 = 50;
v = 0.25;
M = 1.305;
elim = 0.92;
Gamma = 0.0375;
xi = 0.6;
Pa = 101;
h1 = 4.45;
h2 = 4.2;
n = 1;
d0 = 1;
m = 0.5;
p01 = input('Give value for p0(1) =')
q01 = input('Give value for qo(1) =')
e01 = input('Give value for e0(1) =')
p02 = input('Give value for p0(2) =')
q02 = input('Give value for qo(2) =')
e02 = input('Give value for e0(2) =')
p03 = input('Give value for p0(3) =')
q03 = input('Give value for qo(3) =')
e03 = input('Give value for e0(3) =')
eq = deq0*100;
while eq < 40
eq = eq + deq0*100;
% For the first analysis
Psi1 = e01-(elim-Gamma*(p01/Pa)^xi);
eta1 = q01/p01;
G1 = G0*(((2.97-e01)^2)/(1+e01))*(sqrt(p01*Pa));
K1 = G1*((2*(1+v))/(3*(1-2*v)));
d1 = d0*(exp(m*Psi1)-(eta1/M));
kp1 = (h1-h2*e01)*G1*((M/eta1)-exp(Psi1*n));
dq1 = (-kp1*deq0/eta1*(d1*eta1/kp1-1/K1))/(d1/kp1-(d1*eta1/kp1-1/K1)*kp1/eta1*(1/(3*G1)+1/kp1));
dp1 = kp1/eta1*((1/(3*G1)+1/kp1)*dq1-deq0);
p01 = p01 + dp1;
q01 = q01 + dq1;
% For the second analysis
Psi2 = e02-(elim-Gamma*(p02/Pa)^xi);
eta2 = q02/p02;
G2 = G0*(((2.97-e02)^2)/(1+e02))*(sqrt(p02*Pa));
K2 = G2*((2*(1+v))/(3*(1-2*v)));
d2 = d0*(exp(m*Psi2)-(eta2/M));
kp2 = (h1-h2*e02)*G2*((M/eta2)-exp(Psi2*n));
dq2 = (-kp2*deq0/eta2*(d2*eta2/kp2-1/K2))/(d2/kp2-(d2*eta2/kp2-1/K2)*kp2/eta2*(1/(3*G2)+1/kp2));
dp2 = kp2/eta2*((1/(3*G2)+1/kp2)*dq2-deq0);
p02 = p02 + dp2;
q02 = q02 + dq2;
% For the third analysis
Psi3 = e03-(elim-Gamma*(p03/Pa)^xi);
eta3 = q03/p03;
G3 = G0*(((2.97-e03)^2)/(1+e03))*(sqrt(p03*Pa));
K3 = G3*((2*(1+v))/(3*(1-2*v)));
d3 = d0*(exp(m*Psi3)-(eta3/M));
kp3 = (h1-h2*e03)*G3*((M/eta3)-exp(Psi3*n));
dq3 = (-kp3*deq0/eta3*(d3*eta3/kp3-1/K3))/(d3/kp3-(d3*eta3/kp3-1/K3)*kp3/eta3*(1/(3*G3)+1/kp3));
dp3 = kp3/eta3*((1/(3*G3)+1/kp3)*dq3-deq0);
p03 = p03 + dp3;
q03 = q03 + dq3;
end
Essentially, I would like to plot the corresponding p, q and eq for each analysis but with the way it is currently set out, it is only producing 1 number for each.
Any help will be appreciated. I haven't used the program in a few years so forgive my poor layout.
I have the following parameter input;
G0 = 50;
v = 0.25;
M = 1.305;
elim = 0.92;
Gamma = 0.0375;
xi = 0.6;
Pa = 101;
h1 = 4.45;
h2 = 4.2;
n = 1;
d0 = 1;
m = 0.5;
p01 = input('Give value for p0(1) =')
q01 = input('Give value for qo(1) =')
e01 = input('Give value for e0(1) =')
p02 = input('Give value for p0(2) =')
q02 = input('Give value for qo(2) =')
e02 = input('Give value for e0(2) =')
p03 = input('Give value for p0(3) =')
q03 = input('Give value for qo(3) =')
e03 = input('Give value for e0(3) =')
eq = deq0*100;
while eq < 40
eq = eq + deq0*100;
% For the first analysis
Psi1 = e01-(elim-Gamma*(p01/Pa)^xi);
eta1 = q01/p01;
G1 = G0*(((2.97-e01)^2)/(1+e01))*(sqrt(p01*Pa));
K1 = G1*((2*(1+v))/(3*(1-2*v)));
d1 = d0*(exp(m*Psi1)-(eta1/M));
kp1 = (h1-h2*e01)*G1*((M/eta1)-exp(Psi1*n));
dq1 = (-kp1*deq0/eta1*(d1*eta1/kp1-1/K1))/(d1/kp1-(d1*eta1/kp1-1/K1)*kp1/eta1*(1/(3*G1)+1/kp1));
dp1 = kp1/eta1*((1/(3*G1)+1/kp1)*dq1-deq0);
p01 = p01 + dp1;
q01 = q01 + dq1;
% For the second analysis
Psi2 = e02-(elim-Gamma*(p02/Pa)^xi);
eta2 = q02/p02;
G2 = G0*(((2.97-e02)^2)/(1+e02))*(sqrt(p02*Pa));
K2 = G2*((2*(1+v))/(3*(1-2*v)));
d2 = d0*(exp(m*Psi2)-(eta2/M));
kp2 = (h1-h2*e02)*G2*((M/eta2)-exp(Psi2*n));
dq2 = (-kp2*deq0/eta2*(d2*eta2/kp2-1/K2))/(d2/kp2-(d2*eta2/kp2-1/K2)*kp2/eta2*(1/(3*G2)+1/kp2));
dp2 = kp2/eta2*((1/(3*G2)+1/kp2)*dq2-deq0);
p02 = p02 + dp2;
q02 = q02 + dq2;
% For the third analysis
Psi3 = e03-(elim-Gamma*(p03/Pa)^xi);
eta3 = q03/p03;
G3 = G0*(((2.97-e03)^2)/(1+e03))*(sqrt(p03*Pa));
K3 = G3*((2*(1+v))/(3*(1-2*v)));
d3 = d0*(exp(m*Psi3)-(eta3/M));
kp3 = (h1-h2*e03)*G3*((M/eta3)-exp(Psi3*n));
dq3 = (-kp3*deq0/eta3*(d3*eta3/kp3-1/K3))/(d3/kp3-(d3*eta3/kp3-1/K3)*kp3/eta3*(1/(3*G3)+1/kp3));
dp3 = kp3/eta3*((1/(3*G3)+1/kp3)*dq3-deq0);
p03 = p03 + dp3;
q03 = q03 + dq3;
end
Essentially, I would like to plot the corresponding p, q and eq for each analysis but with the way it is currently set out, it is only producing 1 number for each.
Any help will be appreciated. I haven't used the program in a few years so forgive my poor layout.