convert math expression to matlab code

8 views (last 30 days)
Bourne Zhang
Bourne Zhang on 20 May 2023
Answered: Dongyue on 23 May 2023
Hello Experts and community members,
I am sorry but I am new to Matlab, and would like to know How can I conver the following math expression to matlab code?
and I am lerning the paper of WOA, whale optimization algorithm, so if I would like to add the above to the function, anything I need to pay attention to?
Thank you so much in advance for any input and insights!
  1 Comment
John D'Errico
John D'Errico on 20 May 2023
If you are new to MATLAB, then if someone gives you highly optimized code to do this will be useless. You won't understand it, and it would take a couple of pages of explanation to get you to understand what it does, and you still won't be able to write a similar function yourself the next time. Yes, the objective is a quadratic functional of the vector w, with linear constraints. So you should be able to write this as a call to quadprog. But it sounds as if you are asking how to write this for your own optimizer.
Instead, just learn to write the objective using LOOPS. Loops are simple. And the call to optimize it, if you were using a tool like fmincon will be simple, but any other tool that allows a linear equality constraint and bound constraints would suffice.

Sign in to comment.

Answers (1)

Dongyue
Dongyue on 23 May 2023
You can try MATLAB Optimization Toolbox
Please go through the following link for more information:

Categories

Find more on Linear Programming and Mixed-Integer Linear Programming 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!