フィルターのクリア

How can i solve this equation with for loop?

2 ビュー (過去 30 日間)
Volkan Yangin
Volkan Yangin 2017 年 3 月 9 日
コメント済み: Volkan Yangin 2017 年 3 月 9 日
y=[1 4 5 6 8]
for g=1:1:numel(y)
W1(g)=15*y(g)
W2(g)=@(x) x.^2+y(g)
f(g) = @(x) W1(g)+W2(x)+y(g);
ar = [-100 100];
for k1 = 1:length(ar);
rts(k1) = fzero(f(g), ar(k1))
end
end
Error: FUN must be a function, a valid string expression, or an inline function object.
To calculate the roots of this equation, for loop must be used, but i made a mistake when writing the code. How can i achieve this problem?
To find 5 roots of x, how kind of a change must be done for this operation?

採用された回答

Torsten
Torsten 2017 年 3 月 9 日
y = [1 4 5 6 8];
for g=1:1:numel(y)
W1 = 15*y(g);
W2 = @(x)x.^2+y(g);
f = @(x) W1+W2(x)+y(g);
ar=[-100 100];
for k1 = 1:length(ar)
rts(k1,g)=fzero(f,ar(k1));
end
end
But to tell you in advance: Your equations have no real roots.
Best wishes
Torsten.
  1 件のコメント
Volkan Yangin
Volkan Yangin 2017 年 3 月 9 日
Thank you Torsten. This is a random equation. I am checking the code.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by