Results 1 to 5 of 5

Math Help - fmincon on vectorvalued function?

  1. #1
    Senior Member Twig's Avatar
    Joined
    Mar 2008
    From
    Gothenburg
    Posts
    396

    fmincon on vectorvalued function?

    Hi

    In MATLAB, can one use the fmincon function on a vectorvalued function?
    I can't get it to work.

    thanks!
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Twig View Post
    Hi

    In MATLAB, can one use the fmincon function on a vectorvalued function?
    I can't get it to work.

    thanks!
    What would a minimum of a vector look like?

    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Senior Member Twig's Avatar
    Joined
    Mar 2008
    From
    Gothenburg
    Posts
    396

    Hi

    hi CB

    good point, I need to rethink this a bit probably.

    My problem is, I need to use fmincon to maximize distance between 6 points on a unit sphere in R^3. I need in some way find an expression for calculating the distance from every point to every other point?

    I just thought maybe it would be easiest in some way if I were to put the different points in a matrix or something..

    Also obv, I need to write a nonlinear constraint function.

    I guess it would be something like:

    function [c,ceq]=confun(x)

    c=[] %No less than constraints
    ceq=x(1).^2 + x(2).^2 + x(3).^3 - 1
    end

    But I need this constraint for 6 points..

    thanks!
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by Twig View Post
    hi CB

    good point, I need to rethink this a bit probably.

    My problem is, I need to use fmincon to maximize distance between 6 points on a unit sphere in R^3. I need in some way find an expression for calculating the distance from every point to every other point?

    I just thought maybe it would be easiest in some way if I were to put the different points in a matrix or something..

    Also obv, I need to write a nonlinear constraint function.

    I guess it would be something like:

    function [c,ceq]=confun(x)

    c=[] %No less than constraints
    ceq=x(1).^2 + x(2).^2 + x(3).^3 - 1
    end

    But I need this constraint for 6 points..

    thanks!
    Write a function to calculate the distance between two points lets call it d(x,y) , then the sum of the distances between the points is:

    D=\sum_{i=1}^6 \sum_{j=i+1}^6 d(x_i,x_j)

    If you represent your points in sphereical polars you will not need constraints

    CB
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Senior Member Twig's Avatar
    Joined
    Mar 2008
    From
    Gothenburg
    Posts
    396

    hi

    hi

    I am having a bit trouble with this. Need a bit more guidance.

    function y=sumfunc(x)
    for j=1:6
    for k=j+1:6
    y=-norm([x(k,1)-x(k-1,1) x(k,2)-x(k-1,2) x(k,3)-x(k-1,3)])
    end
    end

    This is supposed to be the function calculating distance.


    function testasumfunc()
    clc
    %A=[1 0 0;-10 0 0]
    A=rand(6,3);
    [X,fval]=fmincon(@sumfunc,A,[],[],[],[],[],[],@confun);

    X
    norm(X(1,) %DOES NOT EQUAL ONE, not working
    end


    %Constraint function
    function [c,ceq]=confun(x)
    c=[];
    ceq=x(1).^2 + x(2).^2 + x(3).^2 -1;
    end
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 20
    Last Post: November 27th 2012, 05:28 AM
  2. Replies: 0
    Last Post: October 19th 2011, 04:49 AM
  3. Matlab - Running fmincon with ODE45 in seperate M-file
    Posted in the Math Software Forum
    Replies: 6
    Last Post: August 10th 2011, 02:00 PM
  4. Replies: 4
    Last Post: October 27th 2010, 05:41 AM
  5. Replies: 3
    Last Post: September 14th 2010, 02:46 PM

Search Tags


/mathhelpforum @mathhelpforum