# array indices and bisector method

조회 수: 1(최근 30일)
Michael 2021년 1월 21일
댓글: James Tursa 2021년 1월 22일
Hello,
I'm trying to find a root using the bisector method, using two functions I've made in previous files. Those functions are [PForce, LoadingDuration]= myfunction(x) and [z]= PFunction (m,k,x). I replaced the x by xL, xM and xU which are the values used to calculate the root. Each time I run it it says
Array indices must be positive integers or logical values.
Error in exercice2 (line 10)
z(xL) = PDFunction (m,k,xL);
I'm not really sure how to correct this so if anyone know i'd be happy to know !! Thanks a lot
Here is the full code:
clc;clear;
m=800; k=1e6;
xL=0; xU= 10; Difference=1;
tstep=0.0001;
while Difference > 0.0005
xM = (xU-xL)/2;
z(xL) = PDFunction (m,k,xL);
z(xU) = PDFunction (m,k,xU);
z(xM) = PDFunction (m,k,xM);
MaxdL= max(deflectionL);
MaxdU= max(deflectionU);
MaxdM= max(deflectionM);
if MaxdM > 0.1
xL=xM;
else
xU=xM;
end
Difference = abs(MaxdM-0.1);
end

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

### 답변(1개)

James Tursa 2021년 1월 21일
편집: James Tursa 2021년 1월 21일
It is not clear what z is supposed to be used for in these lines:
z(xL) = PDFunction (m,k,xL);
z(xU) = PDFunction (m,k,xU);
z(xM) = PDFunction (m,k,xM);
You could simply delete these lines.
It is also not clear where the deflection variables are defined.
##### 댓글 수: 1표시숨기기 없음
James Tursa 2021년 1월 22일
So could you just do this?