How to define functions in MATLAB.

3 views (last 30 days)
sudha chandrakar
sudha chandrakar on 16 Nov 2013
Answered: Image Analyst on 16 Nov 2013
while writing the code
ff='testfunction';
cost=feval(ff,par);
I got the error undefined function testfunction for input arguments of type double.

Answers (1)

Image Analyst
Image Analyst on 16 Nov 2013
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.

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!