Undefined Function or Variable

Hi, can anyone see why I am getting the error message '''Undefined Function or Variable R'' . As far as I understand I had already defined R...
Many thanks!
gamma = 15; % Unit weight, Kg/m^3
colRadius = 0.17; % Column Radiu, m
theta = 1*(180/pi); % Angle of failure to the horizaontal surface
phi = 15*(180/pi); % Angle of internal friction
depth = zeros(14,2); % Depth, m
for i = 1:19
depth(i,1)=i;
depth(i,2)=2.25+(0.5*i);
p(i,1) = gamma*depth(i,2)*((depth(i,2)/colRadius)^2+(3*(depth(i,2)/colRadius)*tan(theta))+(3*tan(theta)*tan(theta)))/(3*tan(theta)*tan(theta))*(1+(2*(1-sin(phi)*cos((180*(180/pi))-(theta+phi))))/(cos(phi*cos(theta))));
end
gamma = 15; % Unit weight, Kg/m^3
colRadius = 0.17; % Column Radiu, m
theta = 1*(180/pi); % Angle of failure to the horizaontal surface
phi = 15*(180/pi); % Angle of internal friction
E = 2 ; % Modulus of soil deformation, Kpa
n = 1; % Exponant in empirical equation
p = (200); % Applied pressure at the grout soil interface, kPa
c = 5% cohesion
Ri = 0.06; % Drill radius
Ir = 5 % Rigidity index of soil
v = 2 % Poisson's ratio
q = 2 % Initial Isotropic Ground Stress
a1 = ((1/Ir)-1+1*(-(1+v/2*E))*(4*sin(p)/3-sin(phi))*(q+c*cot(phi)))^3;
a2 = c*cot(phi);
a3 = (3*(1+sin(phi))/(3-sin(phi))*(q+c*cot(phi)));
a4 = (3*(1-sin(phi)))/(4*sin(phi));
a5 = (1/Ir);
try
R = (Ri/(a1(p+a2/a3)^a4)+(a3/p+a2)^a4)-a5^(1/3);
catch
end
figure;
hold on
plot(p,R)
xlabel('Injection Pressure (KPa)');
ylabel('Bulb Radius (kPa)');
MATLAB Question.png

 Risposta accettata

Dimitris Kalogiros
Dimitris Kalogiros il 3 Ott 2019
Modificato: Dimitris Kalogiros il 3 Ott 2019

0 voti

I think there is a typo at the formula that calculates R :
Something is missing there. Maybe a + or * mark
By the way, calculation of R gives an error. Since you have enclose it inside "try-catch" , there is no variable R when the script is trying to plot it.
Correct the typo, remove try-catch and try again....

1 Commento

Thank you, I had not noticed that I had missed a *.
Kind regards,
James

Accedi per commentare.

Più risposte (1)

meghannmarie
meghannmarie il 3 Ott 2019
Modificato: meghannmarie il 3 Ott 2019

1 voto

You are not setting R becuase you have it in a try catch block and it is throwing an error. That is because you are tryind to index a1, but are you really wanting to multiply a1?
Should:
R = (Ri/(al(p+a2/a3)^a4)+(a3/p+a2)^a4)-a5^(1/3)
actually be:
R = (Ri/(al*(p+a2/a3)^a4)+(a3/p+a2)^a4)-a5^1/3

2 Commenti

meghanmarie had flagged this answer:
Flagged by meghannmarie about 1 hour ago.
It marked my answer as spam and it is not
I had marked the answer not spam and I am removing the flag.
Thank you very much! this sorted it out perfectly.
Kind regards,
James

Accedi per commentare.

Categorie

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by