I have a function that gives two outputs, what is the easiest way to use fzero on only the second output

12 ビュー (過去 30 日間)
I have a function [a,b] = fun(x) when I don't want to change the function. I want to find the value of x for which b returns zero. What is the simplest way to get fzero to work here? Currently my best option is to write a second function
function [b] = fun2(x)
[~,b] = fun(x); return
but there must be a better way.

採用された回答

David H
David H 2019 年 10 月 23 日
No good way of doing this within Fzero, people have made that clear.

その他の回答 (1 件)

Matt J
Matt J 2018 年 2 月 14 日
but there must be a better way.
Nope.
  4 件のコメント
Matt J
Matt J 2019 年 10 月 22 日
How? Like any nested or anonymous function.
Simona Giglioli
Simona Giglioli 2019 年 10 月 23 日
But then if I use fzero in the main code, it doesn't recognise the function

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by