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: Matlab running out of memory on code

  1. Nov 7, 2015 #1
    1. The problem statement, all variables and given/known data
    I am trying to run code for the code below but matlab runs out of data.

    3. The attempt at a solution
    NumberOfVariables = 9;
    integers = 0:k-1;
    numbers = 1:k-1;
    s = combnk(integers,NumberOfVariables);
    AllAnswers = [];
    for i = 1:size(s,1)
    G = [(G(:,1)'-G(:,2)') (G(:,2)'-G(:,1)')];
    G = sort(mod(G,k));
    if (isequal(G,numbers))
    AllAnswers = [AllAnswers;s(i,:)];

    I am trying to find the numbers that satisfy the condition in the code. I want the first AllAnswers that do not contain zeros for NumberOfVariables = 9,10,12,14,17,20?I wrote code for the for loops, but as we all know that doesn't scale favorably in computational time and matlab crashes.
  2. jcsd
  3. Nov 8, 2015 #2


    Staff: Mentor

    I would try placing print statements inside the code to see how large each array is as you keep adding stuff to the all answers array.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted