Results 1 to 2 of 2

Math Help - is there any function in MATLAB?

  1. #1
    Member
    Joined
    Mar 2008
    Posts
    84

    is there any function in MATLAB?

    I have 10 integers.
    I want to perform certain operations using any 4 integers.

    Example, given integers 5,8,8,3,4,0,9,2,2,3.
    I want to find 4 integers from the 10 integers given above such that the sum of the 4 integers is equal to 24.

    9+8+3+4=24



    It looks like 10C_{4}. If I use if-else, the program will be very very long. I just wonder is there any built-in function can help me.
    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 deniselim17 View Post
    I have 10 integers.
    I want to perform certain operations using any 4 integers.

    Example, given integers 5,8,8,3,4,0,9,2,2,3.
    I want to find 4 integers from the 10 integers given above such that the sum of the 4 integers is equal to 24.

    9+8+3+4=24



    It looks like 10C_{4}. If I use if-else, the program will be very very long. I just wonder is there any built-in function can help me.
    Code:
    a=[5,8,8,3,4,0,9,2,2,3];
    for i1=1:10
      for i2=i1+1:10
        for i3=i2+1:10
          for i4=i3+1:10
    
             do whatever with a(i1),a(i2),a(i3),a(i4)
    
          end
        end
      end
    end
    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. need a matlab function
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 1st 2011, 10:52 PM
  2. Matlab function
    Posted in the Math Software Forum
    Replies: 2
    Last Post: April 17th 2010, 08:11 PM
  3. Please help with MATLAB function
    Posted in the Math Software Forum
    Replies: 1
    Last Post: April 16th 2010, 04:21 AM
  4. need help with matlab function
    Posted in the Math Software Forum
    Replies: 2
    Last Post: March 24th 2010, 09:47 AM
  5. Matlab while function
    Posted in the Math Software Forum
    Replies: 1
    Last Post: May 9th 2009, 11:46 PM

Search Tags


/mathhelpforum @mathhelpforum