"@" inside fzero command. I get an erro why?

1 回表示 (過去 30 日間)
Douglas Alves
Douglas Alves 2014 年 6 月 2 日
コメント済み: Douglas Alves 2014 年 6 月 2 日
I've got 2 .m files. The line which calls the second file is
[f1 q] = fzero(@avaliator,const.guessf1,const)
it'll call avaliator (.m file)
function q = avaliator
e = -100 ;
[r,y] = integrator(const);
q = sqrt((y(end,2)/const.Total_mass)^2 + (r(end)^e/const.Total_Radius)^2)*(y(end,2).../const.Total_mass) ;
the problem is that it only calls avaliator if I take the "@" out. I think it's because of "@" is for calling functions right? But in another code very similar to this "@" is used with no problem and the .m file called is not a function but something like this avaliator file I posted. Does anyone know why it's returning an error? (suppose all the const.'something' known)

採用された回答

Matt J
Matt J 2014 年 6 月 2 日
編集済み: Matt J 2014 年 6 月 2 日
It's because avaliator is not written to accept an input argument. It needs to be.
function q = avaliator(x)
q=%do something with x
  1 件のコメント
Douglas Alves
Douglas Alves 2014 年 6 月 2 日
I actually put function q = avaliator(const) in order to const be recognized when it comes in avaliator. But it's not recognized either. I should've put [] between const.guessf1 and const anyways. But it doesn't change anything. lol I think I've got multiples errors here..

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by