フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

fzero: not a valid initial bracketing

1 回表示 (過去 30 日間)
Pedro Almeida
Pedro Almeida 2022 年 12 月 11 日
閉鎖済み: Walter Roberson 2022 年 12 月 12 日
format long
y = @(x) 1 - sin(x);
z = @(x) x.^2;
test1 = @(x) (y(x)-z(x));
test2 = @(x) (z(x) - y(x));
ta = 0;
a = 0;
dados = [];
zero = fzero(test1,[0 1])
while (ta != 1)
a = a + 1;
y1 = @(x) (a - sin(x));
funcao = @(x) (y1(x) - z(x));
intervalo = [0+a 1+a];
ta = fzero(funcao, intervalo);
if (ta = 1)
dados = [dados, a];
endif
endwhile
disp(dados)
It gives me that error and I don't really know how to fix it. Any help would me appreciated!!
  1 件のコメント
Torsten
Torsten 2022 年 12 月 12 日
編集済み: Torsten 2022 年 12 月 12 日
Your code is weird and in part not MATLAB compatible:
while / endwhile does not exist in MATLAB; it's while / end
ta != 1 has to be replaced by ta ~= 1
if (ta = 1) has to be replaced by if ta==1
Maybe you should explain in your own words what you try to do.
The error message means that the interval you provided as initial guess for fzero does not satisfy that the function, applied to the endpoints of this interval, gives values that differ in sign.

回答 (0 件)

この質問は閉じられています。

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by