フィルターのクリア

Using the bisection method

2 ビュー (過去 30 日間)
Aaron
Aaron 2013 年 9 月 22 日
I'm not sure if I used the bisection method correctly. Do I have to have two separate .m files? Is the code below okay?
T_o = 300;
T = 1000;
u_o = 1360;
q = 1.7e-19;
n_i = 6.21e9;
p_desi = 6.5e6;
N = [0 2.5e10];
n = @(N) 0.5*(N + sqrt(N.^2 + 4*n_i^2));
u = u_o*(T/T_o)^-2.42;
p = @(N) (1./(q*n(N)*u)) - p_desi;
hold on
plot(N,p(N))
x_l = 9.8e9;
x_u = 9e9;
for i = 1:1:100
x_r = (x_u+x_l)/2;
if ((p(x_l).*p(x_r)) < 0)
x_u = x_r;
else
x_l = x_r;
end
plot(x_r,p(x_r),'k-')
end
hold off
  2 件のコメント
Matt J
Matt J 2013 年 9 月 22 日
編集済み: Matt J 2013 年 9 月 22 日
Can't you tell if it's working by testing it?
I hope this is homework, BTW. Otherwise, you are unnecessarily re-inventing the wheel. FZERO is already available for finding roots, and may do better than bisection.
Aaron
Aaron 2013 年 9 月 22 日
I did run it but the correct graph was a decreasing curved line. Mine is just a straight, decreasing line.
Its not really homework, just practice stuff for the homework to come. I am aware of the FZERO option, but just wanted to try this out.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by