Getting 3 zeros from a function using fzero
古いコメントを表示
I'm trying to collect the 3 zeros over the interval [-5,5] for the function in my code below. I can't seem to figure out how to used the fzero function so I can collect all three zero values and store them.
my_function = @(x) (-x^2 - 5*x - 3 + e^x);
a = fzero(my_function,[-5 5]);
採用された回答
その他の回答 (1 件)
Fangjun Jiang
2011 年 10 月 16 日
Are there three zeros? I only get one. Use exp(x), instead of e^x
>> my_function = @(x) (-x^2 - 5*x - 3 + exp(x));
a = fzero(my_function,[-5 5])
a =
-4.306510588580705
3 件のコメント
Ashikur
2011 年 10 月 16 日
This is not what he asked for, I think he is looking for all the solution in that limit. My solution is in below.
Walter Roberson
2011 年 10 月 16 日
There are 3 zeros,
-.5426539024,
3.482467600,
-4.306510589
Remember, fzero stops when it finds a single zero.
Fangjun Jiang
2011 年 10 月 16 日
That is good to know. I didn't spend time on it. I thought the OP could get there after passing the e^x error.
カテゴリ
ヘルプ センター および File Exchange で Surrogate Optimization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!