フィルターのクリア

Solving for Zeros Across a Range

2 ビュー (過去 30 日間)
Tony Stianchie
Tony Stianchie 2023 年 3 月 4 日
回答済み: Sulaymon Eshkabilov 2023 年 3 月 4 日
I'd like to solve and store the valves for which bi = 0 across a range i=I
H = 0.1;
I = 200;
bi = zeros(I,1);
for i = linspace(1,I)
bi(i,1) = fzero(@(bi)(bi+H*tan(bi)),0);
end
  1 件のコメント
Matt J
Matt J 2023 年 3 月 4 日
You seem to have abandoned this post from several weeks ago, leaving it without an Accepted answer.

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

回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023 年 3 月 4 日
There is an err in the loop in i = linspace(1,I) leads to non integer value that is NOT acceptable for an index. Here is a corrected code:
H = 0.1;
I = 200;
BI = zeros(I,1); % Memory allocation
b=pi; % Initial solution search near this value: b0
for i = 1:I
b = fzero(@(b)(b+H*tan(b)),b);
BI(i) = b;
end
BI(end) % final solution after 200 iterations
ans = -2.7709e-136

カテゴリ

Help Center および File ExchangeSudoku についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by