Invalid use of operator.
2 ビュー (過去 30 日間)
古いコメントを表示
fun =@(Two-((Two-Tso)/(1+(Ks/Kw)))-((Ks/Kw)*((Two-Tso)/(1+(Ks/Kw))))*exp((-Ks-Kw)*tsf))-Tsf;
hA = fzero(fun,10)
With the above function, and all varibles accounted for, I am gettin getting the error below in regards to 1st minus sign. Why?
>> Project1b
Error: File: Project1b.m Line: 31 Column: 11
Invalid use of operator.
0 件のコメント
回答 (2 件)
Walter Roberson
2020 年 10 月 27 日
The syntax for anonymous functions is @(list of variables) body
Instead you have @(expression) -Tsf
0 件のコメント
Steven Lord
2020 年 10 月 27 日
Let's play "Count the parentheses". The way to play:
- Start a counter at 0.
- Whenever you see a ( add 1 to the counter.
- Whenever you see a ) subtract 1 from the counter.
If the counter ever goes negative, you have too few left parentheses or too many right parentheses or you have them in the wrong places.
If the counter does not go to 0 at the end of the line, you don't have enough right parentheses.
With Walter's suggestion about adding the right parenthesis for the input argument of the anonymous function, here's what I see when I play:
fun =@(Two) -((Two-Tso)/(1+(Ks/Kw)))-((Ks/Kw)*((Two-Tso)/(1+(Ks/Kw))))*exp((-Ks-Kw)*tsf))-Tsf;
0 1 0 12 1 2 3 210 12 1 23 2 3 4 3210 12 1 0X
X is where the counter would go to -1. Determine which is the correct ) to delete. I would consider defining a different variable, maybe R for ratio, and using it in place of the value Ks/Kw to eliminate a few sets of parentheses.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Entering Commands についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!