I am trying to use the matlab function, fsolve.
I have an equation L = y*Um^2 - x*Um. I want to set L = 0, and input the value of x. Um is a function of both x and y,but I don't know it without y. I want to solve this equation for y. Please help!
My script so far is this: function F = findy(x,y) f1 = y*Um^2 - x*Um
x = 5.5; b = fsolve(@findy,x);
These two are in two different scripts. I keep getting the error: 'Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.'
Can anyone help me!

回答 (1 件)

Torsten
Torsten 2015 年 10 月 22 日
編集済み: Torsten 2015 年 10 月 22 日

0 投票

function main
x = 5.5;
L = 0;
y0 = 10;
b = fsolve(@(y)findy(y,x,L),y0);
function F = findy(y,x,L)
Um = ...;
F = y*Um^2 - x*Um - L ;
Best wishes
Torsten.

2 件のコメント

Lwalder1993
Lwalder1993 2015 年 10 月 22 日
編集済み: Lwalder1993 2015 年 10 月 22 日
Thanks for such a quick reply! My problem is I don't know Um, without knowing y? And what is y0?
Many thanks, Lydia
Torsten
Torsten 2015 年 10 月 22 日
I edited the code from above.
Calculate Um from x and y in the line
Um = ...;
y0 is a starting guess for y.
Best wishes
Torsten.

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

カテゴリ

ヘルプ センター および File Exchange で Programming についてさらに検索

タグ

質問済み:

2015 年 10 月 22 日

コメント済み:

2015 年 10 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by