Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8466231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:16:50+00:00 2026-06-10T15:16:50+00:00

How do you impose a constraint that all values in a vector you are

  • 0

How do you impose a constraint that all values in a vector you are trying to optimize for are greater than zero, using fmincon()?

According to the documentation, I need some parameters A and b, where A*x ≤ b, but I think if I make A a vector of -1’s and b 0, then I will have optimized for the sum of x>0, instead of each value of x greater than 0.

Just in case you need it, here is my code. I am trying to optimize over a vector (x) such that the (componentwise) product of x and a matrix (called multiplierMatrix) makes a matrix for which the sum of the columns is x.

function [sse] = myfun(x)        % this is a nested function
    bigMatrix = repmat(x,1,120) .* multiplierMatrix;
    answer = sum(bigMatrix,1)';
    sse = sum((expectedAnswer - answer).^2);
end

xGuess = ones(1:120,1);
[sse xVals] = fmincon(@myfun,xGuess,???);

Let me know if I need to explain my problem better. Thanks for your help in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T15:16:51+00:00Added an answer on June 10, 2026 at 3:16 pm

    You can use the lower bound:

    xGuess = ones(120,1);
    lb = zeros(120,1);
    [sse xVals] = fmincon(@myfun,xGuess, [],[],[],[], lb);
    

    note that xVals and sse should probably be swapped (if their name means anything).

    The lower bound lb means that elements in your decision variable x will never fall below the corresponding element in lb, which is what you are after here.

    The empties ([]) indicate you’re not using linear constraints (e.g., A,b, Aeq,beq), only the lower bounds lb.

    Some advice: fmincon is a pretty advanced function. You’d better memorize the documentation on it, and play with it for a few hours, using many different example problems.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to impose some sort of semantic logic for the default values
I'm trying to impose a @Oneto7 association. I'd have imagined an attribute that specifies
So I'm trying to make a console app that imposes a time limit to
I've been trying to build a UI that's as similar as possible to the
C++0x thread library or Boost.thread define a non-member variadic template function that locks all
I am using Symfony 1.2.9, and I have a form that contains two date
Is there any way I can impose a size constraint on a character buffer
According to Eric Evans, associations should Impose a traversal direction Add qualifiers and reduce
Say I need a new type in my application, that consists of a std::vector<int>
Does the recursion heavily impose on processor and ram? I mean, that one of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.