フィルターのクリア

what im doing wrong

1 回表示 (過去 30 日間)
Gentian Zavalani
Gentian Zavalani 2013 年 7 月 6 日
g=@(tu((i),j+1)) tu((i),j+1)-(1/2*(xu((i),j)-xu((i-1),j)+tu((i),j)+tu((i-1),j))+h/8*(r*(tu((i),j)-(1/f)*(tu((i),j))^3)+2*(r*(tu((i),j+1)-(1/f)*(tu((i),j+1))^3))+r*(tu((i-1),j)-(1/f)*(tu((i-1),j))^3)));
p=fzero(@(tu((i),j+1)) g,0);
but i got this answer
Unbalanced or unexpected parenthesis or bracket.

採用された回答

Walter Roberson
Walter Roberson 2013 年 7 月 6 日
When you construct an anonymous function, the part directly after the @ must be pure variable names and not expressions or indexed variables.
Something like
g = @(tu, i, j) tu((i),j+1)-(1/2*(xu((i),j)-xu((i-1),j)+tu((i),j)+tu((i-1),j))+h/8*(r*(tu((i),j)-(1/f)*(tu((i),j))^3)+2*(r*(tu((i),j+1)-(1/f)*(tu((i),j+1))^3))+r*(tu((i-1),j)-(1/f)*(tu((i-1),j))^3)));
p = fzero(@(i) g(tu, i, j), 0)
  2 件のコメント
Walter Roberson
Walter Roberson 2013 年 7 月 6 日
The syntax you are using in
fzero(@(tu((i),j+1)) g,0)
is wrong. What goes in the () after the @ can only be variable names. With what you used, MATLAB is confused when it sees the "g" after the ")" .
Walter Roberson
Walter Roberson 2013 年 7 月 6 日
If you have an expression of the form
f(x) = g(x)
where g(x) is a function of x and includes the term f(x) somewhere inside, then rearrange the expression to
g(x) - f(x) = 0
and then you can solve for the x that makes it zero.
For example if
tu(i) = tu(i) * exp(-i^2) - cos(i)
then you can rearrange that to
tu(i) * exp(-i^2) - cos(i) - tu(i) = 0
and then you
fzero(@(i) tu(i) * exp(-i^2) - cos(i) - tu(i), InitialValue)

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

その他の回答 (1 件)

Gentian Zavalani
Gentian Zavalani 2013 年 7 月 6 日
編集済み: Gentian Zavalani 2013 年 7 月 6 日
As you see this equation is implicit ,i wanna to solve this equation and to find tu((i),j+1) for each iteration so i don't know if you could suggest me any way,how to proceed to for example tu((i),j+1)=s i dont know something like that
pleas if you could give me a answer
regards

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by