fzero of function 3 variables

9 ビュー (過去 30 日間)
raffaele orlando
raffaele orlando 2020 年 4 月 9 日
編集済み: Walter Roberson 2020 年 4 月 9 日
function dydt = eqdiff(t,y,lambda)
dydt=-lambda*y
lambda=1
I write
fzero( @eqdiff(t,y,lambda),2)
matlab give me errore message
how i can solve the zero of a function
  4 件のコメント
Torsten
Torsten 2020 年 4 月 9 日
So in the simple case you stated, you want to know for which value of y the expression -lambda*y becomes zero ?
raffaele orlando
raffaele orlando 2020 年 4 月 9 日
yes

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

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 4 月 9 日
To solve the equation with multiple input variables, use fsolve. Also, the input can be multi-dimensional, but the variable needs to be the same. For example
fsolve(@(x) eqdiff(x(1),x(2),x(3)), zeros(1,3))
function dydt = eqdiff(t,y,lambda)
dydt=-lambda*y;
lambda=1;
end

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 4 月 9 日
fzero() is designed for single functions of one variables that return scalar values.
fsolve() from the Optimization toolbox can handle multiple variables (and multiple functions.)
Sometimes what you can get away with is
fminunc( @(tyl) eqdiff(tyl(1), tyl(2), tyl(3)).^2, initial_values)
However,
function dydt = eqdiff(t,y,lambda)
dydt=-lambda*y
lambda=1
That last line confuses me. You have lambda on input but you assign 1 to it inside the function? What are you expecting that would do for you?
I suspect that you are using the wrong approach to what you are doing. I suspect that you are trying to solve a boundary value problem; see https://www.mathworks.com/help/matlab/boundary-value-problems.html for those.
Your function has trivial solutions: just let y or lambda be 0.

カテゴリ

Help Center および File ExchangeProblem-Based Optimization Setup についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by