필터 지우기
필터 지우기

It keeps giving me an error on line 4, saying I'm missing input arguments but I have everything defined?

조회 수: 1 (최근 30일)
function root = BisectionRoot(Q,q,R,F,z1,z2)
tol = 1e-6;
err = 1.0;
z = (z1 + z2)/2;
fz = Fun(Q,q,R,F,z);
fz1 = Fun(Q,q,R,F,z1);
fz2 = Fun(Q,q,R,F,z2);
while err > tol
if fz1 < 0.0 & fz2 > 0.0
if fz > 0.0
z2 = z;
else
z1 = z;
end
elseif fz1 > 0.0 & fz2 < 0.0
if fz < 0.0
z2 = z;
else
z1 = z;
end
else
disp('The given interval does not contain the root.');
break;
end
z = (z1 + z2)/2;
err = abs(z - z1);
fz = Fun(Q,q,R,F,z);
fz1 = Fun(Q,q,R,F,z1);
fz2 = Fun(Q,q,R,F,z2);
end
root = z;
end
  댓글 수: 4
Stephen23
Stephen23 2024년 3월 3일
"I just pressed the run button once I finished writing it"
So precisely what values do you expect MATLAB to use for the inputs Q,q,R,F,z1,z2 ?
Patrick
Patrick 2024년 3월 3일
Q = 9.4e-6;
q = 2.4e-5;
R=0.1;
F=(Q*q*z) .*((1-z)./(sqrt(z.^2+R.^2)))/(2*epsilon);
epsilon= 0.885e-12;
So would I just add these values to my code?

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

채택된 답변

Torsten
Torsten 2024년 3월 3일
이동: Torsten 2024년 3월 3일
Q = 9.4e-6;
q = 2.4e-5;
R=0.1;
epsilon= 0.885e-12;
F=@(z)(Q*q*z) .*((1-z)./(sqrt(z.^2+R.^2)))/(2*epsilon);
z1 = 0.5;
z2 = 2;
root = BisectionRoot(F,z1,z2)
function root = BisectionRoot(Fun,z1,z2)
tol = 1e-6;
err = 1.0;
z = (z1 + z2)/2;
fz = Fun(z);
fz1 = Fun(z1);
fz2 = Fun(z2);
while err > tol
if fz1 < 0.0 & fz2 > 0.0
if fz > 0.0
z2 = z;
else
z1 = z;
end
elseif fz1 > 0.0 & fz2 < 0.0
if fz < 0.0
z2 = z;
else
z1 = z;
end
else
disp('The given interval does not contain the root.');
break;
end
z = (z1 + z2)/2;
err = abs(z - z1);
fz = Fun(z);
fz1 = Fun(z1);
fz2 = Fun(z2);
end
root = z;
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by