MATLAB: Running function in the command line

Optimization Toolboxrunning function in the command line

I am interested to run optimization (lsqnonlin) in the command line itself without calling or creating a ☆.m file!
clc; clear all
k = 1:10;
fun =@(x) ( 2 + 2*k-exp(k*x(1))-exp(k*x(2)) );
% Next, invoke an optimization routine.
x0 = [0.3 0.4] % Starting guess
[x,resnorm] = lsqnonlin ( fun, x0 );

Best Answer

[x,resnorm] = lsqnonlin( fun, x0, [], [], options );
Parameters are positional. options must appear in the 5th parameter.