Solve equation with 1 unknown numerically

2 ビュー (過去 30 日間)
Niles Martinsen
Niles Martinsen 2014 年 5 月 13 日
回答済み: Star Strider 2014 年 5 月 13 日
I have the following script that defines a function and sets up and equation:
H = @(f) sum(log(f));
f = rand(1, 1);
syms a
H(f)-H(f-a)
I want to solve H(f)-H(f-a)=0 for a. I tried using fzero in the following manner, fzero('H(f)-H(f-a)', 0), but this doesn't yield me anything useful.

回答 (1 件)

Star Strider
Star Strider 2014 年 5 月 13 日
This works:
H = @(f) sum(log(f));
f = rand(1, 1);
a = fzero(@(a) H(f)-H(f-a), 0)
The value of a is, expectedly, zero.

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by