Sridhar Thiagarajan
Sridhar Thiagarajan

Reputation: 580

Cell Array MATLAB

I am trying to use a library for multiple instance learning made by someone else.

This is the main code which explains the input.

function [Concepts,maxConcept,Iterations]=maxDD(PBags,NBags,Dim,Scales,SPoints,Epochs,Tol)


PBags   - An Mx1 cell array, the jth instance of ith positive bag is stored in PBags{i}(j,:) (1<=i<=M)
NBags   - An Nx1 cell array, the jth instance of ith negative bag is stored in Nbags{i}(j,:) (1<=i<=N)

I am new to the concept of cell array. My data is as follows. A text file containing say 400 instances.

First 200 are called positive intances..next 200 called negative.These need to be sorted out into 42 positive bags, then 40 negative bag.(each instances belong to a bag..each bag containig more than 1 instance) (Think of it as red and blue mailboxes.Each mailbox in turn will contain x number of instances (varying for each mailbox) The number of instances in each is given in a (42+40=82) dimensional vector.

example 4 5 6 ...2 meaning 4 intances go to first mailbox, 5 to second and and so on.

How do i give the input in correct cell array form.Since both the data and the algorithm are from the same library, i think somehow that the data i already in a form easily convertable into cell arrays!

Upvotes: 0

Views: 93

Answers (1)

IndefiniteBen
IndefiniteBen

Reputation: 81

This question could definitely be clearer, but based on what I think you mean... I am assuming you have a cell array in your workspace and are trying to input the contents of each instance from that cell array into the MaxDD function you're calling. If you want to input the whole 1*166 vector (an "instance") you use:

PBags{i}

This will return the contents of the cell at location i (which should be an instance). This assumes PBags looks like this when you view the variable: Screenshot of rand-filled cell array

PBags
1x466 cell
_________________________________________________________________
|1x166 double|1x166 double|1x166 double|1x166 double|1x166 double| ...
-----------------------------------------------------------------
|            |            |            |            |            |
-----------------------------------------------------------------
.
.
.

Where each 1x166 double is an instance as mentioned above, and there's 466 instances.

Upvotes: 0

Related Questions