From: Thijs on 16 Jul 2010 05:42 Hello, For a research project at my university i am using Matlab and I am currently facing a problem. I am trying to solve a packing problem, in which I place several pre-defined systems inside a pre-defined envelope. Both the systems and the envelope are defined as matrices. In another part of the code, the systems are placed. The purpose of this part of the code is to find out whether or not two or more systems are in the same cell inside the envelope and, if so, in which cell are they and how many are in that cell. I have included a simplified version of my code: for number_of_system = 1:3 linear_indices{number_of_system} = systems(number_of_system).linear_indices; number_of_indices = numel(systems(number_of_system).linear_indices; lower_bound = (number_of_system - 1) * number_of_indices + 1; upper_bound = number_of_system * number_of_indices; total_row_vector_indices = cell2mat(linear_indices); row_vector_indices_system = total_row_vector_indices(lower_bound:upper_bound); B = histc(row_vector_indices_system, total_row_vector_indices); indices_of_overlap = total_row_vector_indices(B >1); number_of_systems_in_cell = B(B > 1); end The problem is that the 'histc' command does not work (error: edges vector must be monotonically non-decreasing). This is probably due to the fact that the 'total_row_vector_indices' grows by the 'number_of_indices' everytime the 'for'-loop is executed. I hope I have described my problem clearly enough. Does anybody have a solution for this problem with the 'histc' command? Thanks in advance! Thijs
From: Thijs on 16 Jul 2010 05:51 Solved, sorting the total_row_vector_indices before using it as an edges vector solved the problem. Thijs "Thijs " <t.denhamer(a)student.tudelft.nl> wrote in message <i1p9hc$s2j$1(a)fred.mathworks.com>... > Hello, > > For a research project at my university i am using Matlab and I am currently facing a problem. I am trying to solve a packing problem, in which I place several pre-defined systems inside a pre-defined envelope. Both the systems and the envelope are defined as matrices. In another part of the code, the systems are placed. The purpose of this part of the code is to find out whether or not two or more systems are in the same cell inside the envelope and, if so, in which cell are they and how many are in that cell. I have included a simplified version of my code: > > for number_of_system = 1:3 > linear_indices{number_of_system} = systems(number_of_system).linear_indices; > number_of_indices = numel(systems(number_of_system).linear_indices; > > lower_bound = (number_of_system - 1) * number_of_indices + 1; > upper_bound = number_of_system * number_of_indices; > > total_row_vector_indices = cell2mat(linear_indices); > row_vector_indices_system = total_row_vector_indices(lower_bound:upper_bound); > > B = histc(row_vector_indices_system, total_row_vector_indices); > indices_of_overlap = total_row_vector_indices(B >1); > number_of_systems_in_cell = B(B > 1); > end > > The problem is that the 'histc' command does not work (error: edges vector must be monotonically non-decreasing). This is probably due to the fact that the 'total_row_vector_indices' grows by the 'number_of_indices' everytime the 'for'-loop is executed. I hope I have described my problem clearly enough. Does anybody have a solution for this problem with the 'histc' command? > > Thanks in advance! > > Thijs
|
Pages: 1 Prev: cross validation with layer recurrent neural network Next: Problems sharing data between GUI's |