Register to reply

Matlab I am trying to write a function on an M-file

by daher
Tags: function, matlab, mfile, write
Share this thread:
daher
#1
Aug31-07, 05:15 AM
P: 2
Hi All

I am new with Matlab

I am trying to write a function on an M-file; here is the script:

function f = ali(x)
f = - x(1) * x(2);
A = [-1 -2 -2; 1 2 2]
b = [0; 72]
x0 = [10; 10; 10];
[x,fval] = fmincon(@ali,x0,A,b)

Whenever i run it i get the following message;
input argument "x" is undefined

So can anybody help

Best Regards
Phys.Org News Partner Science news on Phys.org
'Office life' of bacteria may be their weak spot
Lunar explorers will walk at higher speeds than thought
Philips introduces BlueTouch, PulseRelief control for pain relief
Pythagorean
#2
Aug31-07, 05:28 AM
PF Gold
Pythagorean's Avatar
P: 4,292
you have to define x when you call the function. How are you running the function?

I would suggest using the command window and calling it with:

f = ali(x)

where x is whatever two numbers you want it to be.

in your second line, you call x(1) and x(2) so there has to be two elements in x
so at your command window, you could enter:

f = ali([5 7]) where I've chosen 5 and 7 arbitrarily.


Register to reply

Related Discussions
Matlab: How to apply filters to and ECG signal using matlab? Math & Science Software 2
SVD with Matlab Math & Science Software 0
Matlab and PDE Math & Science Software 0
Matlab Help! Math & Science Software 3
Help in Matlab! Math & Science Software 0