1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Optimization with constraints matlab

  1. Jun 17, 2014 #1


    User Avatar
    Gold Member

    1. The problem statement, all variables and given/known data
    Just a heads up, this is a problem with parts (a) - (o). I am working on (k). I am working on problem 5 in the attached PDF. I will show my code for the other parts. We were told to use N = 5 while writing the code for debugging and testing, but run N = 500 for the real assignment. Either way, it doesn't make a difference right now because I don't know the synthax for finding indices in arrays for a single index.

    2. Relevant equations

    3. The attempt at a solution
    Code (Text):
    bMin = 0.001;
    bMax = 0.2;
    hMin = 0.001;
    hMax = 0.2;
    Pv = 1000;
    Ph = 100;
    Code (Text):
    N = 500;
    Code (Text):
    bValues = linspace(bMin,bMax,N);
    hValues = linspace(hMin,hMax,N);
    Code (Text):
    B = repmat(bValues,N,1)';
    H = repmat(hValues,N,1);
    Code (Text):
    S1 = (6*Pv)./(B.*H.^2);
    Code (Text):
    S2 = (6*Ph)./(B.^2.*H);
    Code (Text):
    D1 = (4*Pv)./(2e11.*B.*H.^3);
    Code (Text):
    D2 = (4*Ph)./(2e11.*B.^3.*H);
    Code (Text):
    A = B.*H;
    Code (Text):
    constraints = find((S1 < 1e8) & (S2 < 1e8) & (D1 < 0.001) & (D2 < .001));
    nValidDesigns = numel(constraints);
    This is where I am now stuck. I'm not sure what command I can use to find the single index of the valid designs from part (j).
    Code (Text):
    [indexValidDesigns, I] = find((S1 < 1e8) & (S2 < 1e8) & (D1 < 0.001) & (D2 < .001));

    Attached Files:

  2. jcsd
  3. Jun 17, 2014 #2


    User Avatar
    Gold Member

    I just redid what I put in part (j)

    Code (Text):
    indexValidDesigns = find((S1 < 1e8) & (S2 < 1e8) & (D1 < 0.001) & (D2 < .001));
    And the autograder gave said its right. Kind of dumb that part (k) is just the same thing as part(j), no??

    I will put any more questions pertaining to this problem in this thread. Thanks.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted