Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
matrix division

Subject: matrix division

From: Aparna Sampath

Date: 23 Sep, 2010 04:15:24

Message: 1 of 5

Hi All

I am new to using Matlab. I am trying to divide a dataset based on the number of -1 and +1 I have in my dataset. I want to divide it in such a way that each sub matrix has almost equal number of positives and equal number of negatives across matrices. Each sub matrix need not have same number of rows.

eg: i have 18 +1 and 25 -1, and I want to divide it (into 5 submatrices) such a way that each submatrix has 18/5positives and 25/5 negatives in it.
Kindly HELP!

Subject: matrix division

From: Ross W

Date: 23 Sep, 2010 04:42:04

Message: 2 of 5

"Aparna Sampath" <aparna.sampath26@gmail.com> wrote in message <i7ek8s$n8d$1@fred.mathworks.com>...
> Hi All
>
> I am new to using Matlab. I am trying to divide a dataset based on the number of -1 and +1 I have in my dataset. I want to divide it in such a way that each sub matrix has almost equal number of positives and equal number of negatives across matrices. Each sub matrix need not have same number of rows.
>
> eg: i have 18 +1 and 25 -1, and I want to divide it (into 5 submatrices) such a way that each submatrix has 18/5positives and 25/5 negatives in it.
> Kindly HELP!

For your example, what might be a typical size of the dataset (number of rows and columns)?

Does the dataset contain other values which are neither +1 nor -1?

Assuming the dataset has more than one column, do the submatrices all need to be rectangular? (I guess yes)

Ross

Subject: matrix division

From: Walter Roberson

Date: 23 Sep, 2010 04:51:43

Message: 3 of 5

On 22/09/10 11:15 PM, Aparna Sampath wrote:

> I am new to using Matlab. I am trying to divide a dataset based on the
> number of -1 and +1 I have in my dataset. I want to divide it in such a
> way that each sub matrix has almost equal number of positives and equal
> number of negatives across matrices. Each sub matrix need not have same
> number of rows.
> eg: i have 18 +1 and 25 -1, and I want to divide it (into 5 submatrices)
> such a way that each submatrix has 18/5positives and 25/5 negatives in
> it. Kindly HELP!

Hint:

diff(floor(linspace(0,18,6)))

Subject: matrix division

From: Aparna Sampath

Date: 23 Sep, 2010 04:58:04

Message: 4 of 5

Hi Ross

in this dataset i am using it is 50x101. But it might vary, lets say, 10000x101. The values are always -1 and +1. Yes the submatrices shd also be mxn where n remains constant as 101 while the number of rows are divided.





"Ross W" <rosswoodskiwi@hotmail.com> wrote in message <i7elqs$390$1@fred.mathworks.com>...
> "Aparna Sampath" <aparna.sampath26@gmail.com> wrote in message <i7ek8s$n8d$1@fred.mathworks.com>...
> > Hi All
> >
> > I am new to using Matlab. I am trying to divide a dataset based on the number of -1 and +1 I have in my dataset. I want to divide it in such a way that each sub matrix has almost equal number of positives and equal number of negatives across matrices. Each sub matrix need not have same number of rows.
> >
> > eg: i have 18 +1 and 25 -1, and I want to divide it (into 5 submatrices) such a way that each submatrix has 18/5positives and 25/5 negatives in it.
> > Kindly HELP!
>
> For your example, what might be a typical size of the dataset (number of rows and columns)?
>
> Does the dataset contain other values which are neither +1 nor -1?
>
> Assuming the dataset has more than one column, do the submatrices all need to be rectangular? (I guess yes)
>
> Ross

Subject: matrix division

From: Aparna Sampath

Date: 23 Sep, 2010 05:18:04

Message: 5 of 5

Hi

This function gives me the number of positive labels i can split up in each submatrix. This is really helpful. because previously I had written 6-7 lines of code just for getting this. :)

 Can I put this function into a loop and run it for the 50 rows..since, now I know how many positives should go into each sub matrix, but how do i divide the rows accordingly so that the whole matrix splits up into 5 parts with those many positives and negatives.

 

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us