hi, i'm a final yr student. currently i need to write a matlab program which requires the use of an optimising program (fmincon) i'm very new to matlab and i have no idea on writting any of the codes. i was wondering if there is any useful website or reference where i can pick up matlab fast and learn how to use the optimisation program. thanks alot

Dani AI

Generated

A compact, practical plan for (and others in the same situation), with pointers that build on 's reality check that MATLAB takes time to learn.

Recommended learning path:

  • Get the basics first: variables, vectors/matrices, indexing, function handles and simple m-files, and plotting. MathWorks preserves concise beginner material in the official guide: Getting Started with MATLAB.
  • Learn Optimization Toolbox basics next (objective functions, bounds, linear vs nonlinear constraints) and read the fmincon reference and examples: fmincon documentation.
  • Practice on small problems: start with fminsearch or fminunc for unconstrained tests, then add bounds and linear constraints before moving to nonlinear constraints.

A minimal fmincon workflow (copyable template):

fun = @(x) (x(1)-2)^2 + (x(2)-3)^2;
x0  = [0; 0];
lb  = [-5; -5];
ub  = [ 5;  5];
options = optimoptions('fmincon','Display','iter');

[x,fval,exitflag,output] = fmincon(fun,x0,[],[],[],[],lb,ub,[],options);

Key troubleshooting notes:

  • Check exitflag and output.message to see why the solver stopped.
  • Constraint infeasibility is a common failure mode; verify constraint values at x0 before calling fmincon.
  • Poor scaling slows or spoils convergence; set TypicalX in options or rescale variables to similar magnitudes.
  • If performance matters, supply an analytic gradient and set SpecifyObjectiveGradient to true; otherwise use FiniteDifferenceType = 'central' for better accuracy.

Further practical resources: the Optimization Toolbox overview and community examples on MATLAB Central are useful for concrete examples and common patterns: Optimization Toolbox overview.

Recommended Answers

All 2 Replies

i was wondering if there is any useful website or reference where i can pick up matlab fast and learn how to use the optimisation program. thanks alot

i dont think you can pick up matlab fast...

ive been using it for 3 years now... and i still suck at it.

Im sorry for this information.

and as for reference... the only things i have are 2 300+ page books (one solely on matlab, the other dealing with electrical signals by using matlab - both of which are from classes i have taken).

good luck.

yeah i agreed with you, well thank you for your help..you have a great week. cheers

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.