How to define functions in MATLAB.

while writing the code
ff='testfunction';
cost=feval(ff,par);
I got the error undefined function testfunction for input arguments of type double.

回答 (1 件)

Image Analyst
Image Analyst 2013 年 11 月 16 日

1 投票

You need to do this:
function results = testfunction(ff, par)
cost=feval(ff,par);
results = ..... whatever, more code to assign results.
and save it as testfunction.m.

カテゴリ

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

質問済み:

2013 年 11 月 16 日

回答済み:

2013 年 11 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by