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 7579949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:47:47+00:00 2026-05-30T17:47:47+00:00

let’s assume i have the following logical matrix: log = [1 1 0; 0

  • 0

let’s assume i have the following logical matrix:

log = [1 1 0; 
       0 1 1; 
       1 0 1; 
       0 0 1];

the columns describe something like a basket and the single rows describe some objects identified by a certain attribute (e.g. balls of different colors) you could put into those baskets. 1 means, you can put it in (into the basket described by the column), 0 you can’t.

Each basket can only contain ONE object at once.
I’m wondering how to compute the permutations on how to put in objects for a given configurations, that means I say: I want to have objects in basket 1 and 3 but none in basket 2, which would be [1 0 1]:

So I have the following possibilities:

  • basket 2: 0 items
  • basket 1: can contain either object 1 or obj. 3
  • basket 3: can contain either object 2, obj. 3 or obj. 4

so all in all, I have the complete permutations (one line describes one permutation, the column describe the baskets and the number describes the object):

1 0 2
1 0 3
1 0 4
2 0 2
2 0 3
2 0 4

how to make this into a nice algorithm, which adapts to arbitrary number of baskets and objects? i can only think of nested and ugly looping 🙁
thanks a lot!

  • 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-05-30T17:47:49+00:00Added an answer on May 30, 2026 at 5:47 pm

    I would make it recursively:

    function out = permlog(log,bag)
    if bag(1)==0
        curr=0;
    else
        curr = find(log(:,1));
    end
    if size(log,2)==1
        out = curr;
        return
    else
        add = permlog(log(:,2:end),bag(2:end));
        out = [];
        for i=1:numel(curr)
            tmp = [repmat(curr(i),size(add,1),1),add];
            out =[out;tmp];
        end
    end
    

    gives the output you describe:

    permlog(log,[1,0,1])
    
    ans =
    
         1     0     2
         1     0     3
         1     0     4
         3     0     2
         3     0     3
         3     0     4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's have an example like below: package xliiv.sandbox; import android.app.Activity; import android.os.Bundle; import android.util.Log;
Let's assume we have the following class : public class ImageButton extends MovieClip {
Let’s say I have a table with the following columns: EmployeeID, PayEntity, HourWorked, Date
Let's say I have a sortable list like this: $(.song-list).sortable({ handle : '.pos_handle', axis
Let's say I have a string like this: var str = /abcd/efgh/ijkl/xxx-1/xxx-2; How do
Let's say I have a text file composed like this ##### typeofthread1 ##### typeofthread2
Let's say I have the following text: (example) <table> <tr> <td> <span>col1</span> </td> <td>col2</td>
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Let's say I have the following object: var VariableName = { firstProperty: 1, secondProperty:
Let's say I have the following classes : public class MyProductCode { private String

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.