# Undefined Function or Variable

조회 수: 10(최근 30일)
James Leak 2019년 10월 3일
댓글: James Leak 2019년 10월 3일
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
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);
end
gamma = 15; % Unit weight, Kg/m^3
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)'); 댓글을 달려면 로그인하십시오.

### 채택된 답변

Dimitris Kalogiros 2019년 10월 3일
편집: Dimitris Kalogiros 2019년 10월 3일
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표시숨기기 없음
James Leak 2019년 10월 3일
Thank you, I had not noticed that I had missed a *.
Kind regards,
James

댓글을 달려면 로그인하십시오.

### 추가 답변(1개)

meghannmarie 2019년 10월 3일
편집: meghannmarie 2019년 10월 3일
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표시숨기기 이전 댓글 수: 1
James Leak 2019년 10월 3일
Thank you very much! this sorted it out perfectly.
Kind regards,
James

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!