Accessing individual contents of cell array for large amount of cells

  • Permalink
  • submit to reddit
  • Email
  • Follow


I have data thats in a cell in form of doubles, and depending on the data set, the length of this cell can range from about 20 to over 100. I need to access the contents of this cell array individually. I know how I can do this using deal, as in the example from doc:

[a,b,c,d] = deal(C{:})

My question: is there a method for automatically creating an array like [trial1 trial2 trial3 ... trial99] for varying lengths (that are specific to the cell length, of course) without actually doing it manually each time?

Sorry if it's confusing...

Thanks in advance!

Ashley
0
Reply Ashley 4/9/2010 8:22:04 PM

See related articles to this posting


"Ashley " <namehere@thisplace.com> wrote in message <hpo29c$n7l$1@fred.mathworks.com>...
> I have data thats in a cell in form of doubles, and depending on the data set, the length of this cell can range from about 20 to over 100. I need to access the contents of this cell array individually. I know how I can do this using deal, as in the example from doc:
> 
> [a,b,c,d] = deal(C{:})
> 
> My question: is there a method for automatically creating an array like [trial1 trial2 trial3 ... trial99] for varying lengths (that are specific to the cell length, of course) without actually doing it manually each time?

No. The actual data in each of the cells is physically in different parts of memory. When you concatenate some or all of them into a single variable you have to copy all of the individual data contents into a new single block of memory. That can only be done by manually doing it each time.  The alternative is to copy *everything* to one array and then access slices of that array. This latter approach has the advantage that it will ultimately will be faster to access your data this way than concatenating the individual cells each time.

James Tursa
0
Reply James 4/9/2010 8:44:05 PM

"James Tursa" <aclassyguy_with_a_k_not_a_c@hotmail.com> wrote in message <hpo3il$d9o$1@fred.mathworks.com>...
> "Ashley " <namehere@thisplace.com> wrote in message <hpo29c$n7l$1@fred.mathworks.com>...
> > I have data thats in a cell in form of doubles, and depending on the data set, the length of this cell can range from about 20 to over 100. I need to access the contents of this cell array individually. I know how I can do this using deal, as in the example from doc:
> > 
> > [a,b,c,d] = deal(C{:})
> > 
> > My question: is there a method for automatically creating an array like [trial1 trial2 trial3 ... trial99] for varying lengths (that are specific to the cell length, of course) without actually doing it manually each time?
> 
> No. The actual data in each of the cells is physically in different parts of memory. When you concatenate some or all of them into a single variable you have to copy all of the individual data contents into a new single block of memory. That can only be done by manually doing it each time.  The alternative is to copy *everything* to one array and then access slices of that array. This latter approach has the advantage that it will ultimately will be faster to access your data this way than concatenating the individual cells each time.
> 
> James Tursa


Thanks, you've saved me a few hours. 

I actually separated the data and put them into nonuniform cells (that's the only way I know how to separate data based on something without having to do it for each new data set) based on the trial number, so i'd like to keep the data separated because I need to manipulate the data within a trial - separate from the other trials. Is there a more efficient way of doing this?

*fyi: trial - from doing a repeated task

Thanks in advance!

Ashley
0
Reply Ashley 4/9/2010 10:37:03 PM

"Ashley " <namehere@thisplace.com> wrote in message <hpoa6f$l41$1@fred.mathworks.com>...

> Thanks, you've saved me a few hours. 
> 
> I actually separated the data and put them into nonuniform cells (that's the only way I know how to separate data based on something without having to do it for each new data set) based on the trial number, so i'd like to keep the data separated because I need to manipulate the data within a trial - separate from the other trials. Is there a more efficient way of doing this?
> 
> *fyi: trial - from doing a repeated task
> 
> Thanks in advance!
> 
> Ashley

I found a way to extract it to a double in separate columns. Problem solved!

Ashley
0
Reply Ashley 4/12/2010 4:39:05 PM
comp.soft-sys.matlab 203781 articles. 537 followers. Post

3 Replies
440 Views

Similar Articles

[PageSpeed] 21


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

Access to cell array in cell array
Hallo. I have a problem with a cell array. It's a 12x2 cell array. And in the second column in each row of this cell array is again a 13x1 cell array. In the 8th cell there is a column vector. I tried to gain access to this column vector in the 8th cell for finding the minimum at once of all 12 cells in the second column. But I failed. It looks like that: samples_merged{i,2}{8,:} where i runs from 1 to 12. I am able to solve the problem with a loop, sure, but if anyone comes up with an idea without a loop, I would be happy. Kind regards, Gudrun In article <10143048.1204191328840.J...

Breaking Up Large Cell Array into Smaller Cell Arrays
Hello, I have a unique problem. Right now I have a large cell array and I want to break that cell array into smaller cell arrays. Here is a portion of the large cell array: C = [1x35 char] [1x39 char] 'ALAMEDA' 'CA' [1x30 char] [1x20 char] 'ALAMEDA' 'CA' [1x30 char] [1x20 char] 'LUDINGTON' 'MI' [1x30 char] [1x20 char] 'LUDINGTON' 'MI' Now, for this test case I want to break this into two smaller cell arrays according to...

Changing matrices in cell arrays except for one cell array in a cell
Hey guys I need your help once again! I hope someone can show me how to do this. So I have a cell MTT with "d" cell arrays in it, each cell array contains a matrix of nxn and I need to change a whole row of numbers to Inf in every matrix except for one of them which is going to be given by variable "b". MP is a matrix with a dx2 dimension. Here is my code but this will do it for all matrices, I want to find a way to not do it for "b", for d = 1:numMachines; MTT{d}(MP(b,2),:) = Inf; end Now I have tried doing the following but I guess I can not do...

cell contents to non-cell array object
Hopefully a trivial question: This part of my program below opens datafile with two columns(and header) serial date and temp. Reads in serial date, converts to string date and hopefully writes out string date and temp value. Getting error that says: "Cell contents assignment to a non-cell array object." Crashes during 2nd time thru for loop on stringd{i} line. Tried {} brackets, (), parentheses...not sure if strings need to be exact same size. Any suggestions? Thanks, Sheryl [fid] = fopen(filename_in,'rt'); [A,B] = textread(filename_in,'%f %f','headerlines',3...

Cell arrays containing cell arrays
Hi Everyone, I have data in cell arrays containing cell arrays. I would like to extract data from these cell arrays and store in a normal array. I am able to do it for a particular case using nested for loops. But I would like to generalize this problem such that I can extract any kind of cell array containing cell arrays just like cell2mat function does. Please let me know if there is any solution to this problem. Thanks, Anil Palaparthi. Already discussed here: http://www.mathworks.com/matlabcentral/newsreader/view_thread/253738 Bruno Anil Kumar Palaparthi wrote: > I ha...

convert to cell array into a character array or cell array of strings
Hi I have this horizontal array of names: Name Size Bytes Class Attributes itemNames 1x70 7428 cell I need to convert this into a a character array or cell array of strings. I tried: S = char( itemNames) ??? Error using ==> char Cell elements must be character arrays. I tried also: S = cellstr( itemNames) ??? Error using ==> cellstr at 34 Input must be a string. I appreciate your help, thanks, Manal "Manal " <news@mathworks.com> wrote in message <guqdbh$qci$1@fred.mathworks.com>... &...

??? Cell contents reference from a non-cell array object.
In the following code I receive the following error relating to my for loop: ??? Cell contents reference from a non-cell array object. What is the problem? Cheers, Saskia %Produce .jgw files %read in data [im_id, ps, e, n]=textread('mosaic.txt', '%n%n%n%n'); %process [x,junk]=size(ps); zero1=zeros(x,junk); zero2=zeros(x,junk); nps=ps*-1; %write for i=1:x M=[ps(i),zero1(i),zero2(i),nps(i),e(i),n(i)]; dlmwrite(['C:\World files\',im_id{i},'.jgw'], M, 'newline', 'precision', 9) end ...

Cell contents reference from a non-cell array object.
Hi all A.data{1,1}{1}(1) gives me this ??? Cell contents reference from a non-cell array object. do you know why ? any suggestions In article <ef5b8a1.-1@webcrossing.raydaftYaTP>, aa <dragonboy.ali@gmail.com> wrote: >Hi all >A.data{1,1}{1}(1) >gives me this >??? Cell contents reference from a non-cell array object. >do you know why ? >any suggestions We can deduce that either A.data is not a cell array, or else A.data{1,1} is not a cell array. But as to -why- this is so... Sorry, Magic 8-Ball Is Out of Order. -- There are some ideas so wrong that...

delete cells in cell array with certain cell size
Hi there, how can I delete cells (arrays of different length) with a size==1 in a cell array? example for an cell array C. Cells 3 and 6 have a size of 1x2 and have to be deleted: >>C(1:6) ans = [13x2 single] [14x2 single] [1x2 single] [9x2 single] [11x2 single] [1x2 single] I could manage it for empty cells using cellfun % Empty cells in cell arrray will be deleted. C(cellfun(@(C) isempty(C),C))=[]; Thanks Stephan Stephan wrote: > Hi there, > > how can I delete cells (arrays of different length) with a size==1 in a > cell array? ...

Cell contents assignment to anon-cell array object.
I have two listbox listbox one and listbox 2 the user should choose a value from the listbox 1 and add it to the list box 2 %% get the sellected value from listbox 1 list1_val= get(handles.listbox1,'Value'); list1_str= get(handles.listbox1,'String'); handles.mc1=list1_str{list1_val}; % handles.mw1= material code handles.mw1=str2double(get(handles.MW,'String')); %% put it in the listbox 2 % get the value of the sellected item list2_val= get(handles.listbox2,'V...

Expanding Cell Array within a Cell Array
I have a 10000x1 cell array, and within each of those cells a 1x5 cell array. Every cell contains numbers stored as characters. How do i go about converting it to a 10000x5 matrix of doubles? Thankyou in advanced "Jordan" wrote in message <jp1gn9$krj$1@newscl01ah.mathworks.com>... > I have a 10000x1 cell array, and within each of those cells a 1x5 cell array. > > Every cell contains numbers stored as characters. > > How do i go about converting it to a 10000x5 matrix of doubles? > > Thankyou in advanced Jordan: This probably isn't the be...

Part of cell array into another cell array
Hello I would like to know how can I put a part of a cell array into another cell array without use for or while loops. For example: "points" is a cell array of dimensions 1 x 16. The elements of "points" consists on matrices of several sizes. Now I want to introduce "points{1:5}" into another cell array of dimensions 1 x 5 without using loops. How can I do this? Thanks in advance. help deal e.g. [points2{2:6}]=deal(points{1:5}); Jos� L. G�mez wrote: > Hello > > I would like to know how can I put a part of a cell ...

Cell contents reference from a non-cell array object. #2
&#305; have two popup menu in gui first &#305; choese one of them and variable size 150*2 matris then when &#305; callback another for 150*4 matrix it gives this error &#305; cant handle it pls help me what is the reason "ali " <rebelfirst@gmail.com> wrote in message <h6dl0f$3uk$1@fred.mathworks.com>... > &#305; have two popup menu in gui > first &#305; choese one of them and variable size 150*2 matris > then when &#305; callback another for 150*4 matrix it gives this error &#305; cant handle it pls help me what is the reas...

Processing Cell Array of Cell Array of Strings
Hi, So I have a cell array of a cell array of strings that I am working with. As an example consider the following: test=cell(5,1); test{1,1}{1}=num2str(1); test{1,1}{2}=num2str(0); test{2,1}{1}=num2str(0); test{2,1}{2}=num2str(0); test{3,1}{1}=num2str(1); test{3,1}{2}=num2str(1); test{4,1}{1}=num2str(0); test{4,1}{2}=num2str(0); test{4,1}{3}=num2str(0); test{5,1}{1}=num2str(0); test{5,1}{2}=num2str(1); test{5,1}{3}=num2str(0); I want to process this cell array of cell array of strings so that the inside cell array is removed to make it easier to analyze and look at the...

Cell contents reference from a non-cell array object...but only in GUIDE...
I'm running GUIDE and am generating a GUI to interact with a simulation. Basically, I'm trying to create a cell array to contain a log of simulation-generated messages. I have initialized the cell array as a global variable so that it can be updated in different functions. Since I don't want to lose previous messages (they're being saved to get written to file later), the array needs to dynamically concatenate itself with the messages that come in. I have a little code snippet that works in the command window, but when I implement it into the rest of my code, I get my favorite ...

Pb : Cell contents assignment to a non-cell array object
Hello, I have a problem with insering data in a database. I open a database,select a field of the database and try to insert a matrix containing characters. I define this matrix like a cell array. But the result of the insertion is: Cell contents assignment to a non-cell array object Do you have an idea of what is the problem? my program is: db=dbase(bdd,user,password,12) rs=rset(db,'select * from table1 where Name =''Morizet''',1) xc = fields(rs) iris_matrice = {'image001';'image002';'image003';'image004';'image005';'...

image processing cells segmentation count cells amount cells
Hi,this is my image http://drop.io/fq1hhph I need to count all the cells,I ve tried the watershed transform to segment the cells but I haven't a good result.Do you know one method to segment all the cells and to count them or only to count,because i need the number of the total cells. thank you so much!!! You didn't get much help the last time you asked either. That's because no one knows what a cell is in that photo. It's not easy so you can hire a consultant if you want. If *you're* the consultant, then keep plugging away at your job. I suggest you look at mo...

using cell arrays and accessing specific content
Hi guys, I would like to know how to access a cell arrays sectors/ contents which is based on a relational operator. To make it clear I have a cell array Ra={12 123 12 21312 434 132 221 12 123 3 123 131 12} ...... its very lengthy about 2000 matrices inside I would like to access and take out those values which are greater than 100 and less than (100+tol) my tolerance is usually 20. The catch is I wont have exactly 100 in my cell array. So I need to chose a tolerance value. Guys plz help me out on this. I was trying to convert to a normal matrix using cell2mat and then using relational o...

??? Cell contents assignment to a non-cell array object error when using odes15s
I've been using odes15 to solve variouos differential equation models, but over the past couple of days I seem to be getting this error when I try and run most of my programs, even ones that haven't been altered: ??? Cell contents assignment to a non-cell array object. Error in ==> cellstr at 38 c{i} = s(i,:); Error in ==> cell.ismember at 28 if ischar(a), a = cellstr(a); end Error in ==> funfun\private\odefinalize at 19 fullstats = ismember(solver,{'ode15i','ode15s','ode23s','ode23t','ode23tb'}); Error in ==> ode15s at 986 s...

Cell Array: 'Double' and 'Cell' type sub-arrays
Howdy! I'm a NooB, but am making strides. This is my first line casted to MATLAB Central! I am presented with the following 1x45 cell array: [double] [double] [double] {cell} [double] ... [double] -- note the curly brackets around {cell}...why is that? Every sub-array is a 1000x1 column vector. Cells 1-3, and 5-45 all contain numeric data. Cell 4, on the other hand, contains #NAME? and seems to be interpreted as a cell. *** I would like to convert this cell array to a 1000x45 matrix. If all the sub-arrays were [doubles], then the function CELL2MAT would work perfectly. How...

Converting cell array of strings to cell array of numbers
I have x = Columns 1 through 11 '1' '10' '11' '12' '13' '14' '15' '16' '2' '3' '4' Columns 12 through 22 '5' '6' '7' '8' '9' '1' '10' '11' '12' '13' '14' Columns 23 through 33 '15' '16' '2' '3' '4' '5' '6' '7' '8' '9' '1' Co...

Assignment of a cell array to a portion of another cell array
Hello, I have a question. I think my problem has to do with a fundamental lack of knowledge about how indexing works in Matlab. Here is my code: Assume D3 is a data structure containing 3 fields, each field is an nx1 array. D3.F1 = [1 2 3 4] D3.F2 = [5 6 7 8] FL = fieldnames(D3); data{:,3} = num2cell( D3.(FL{2}) ) %so I am trying to fill the third column of cell array "data" with the contents of the array of the second field of D3. What I get is data{1,1} containing a cell which contains the entire cell array of D3.F2. Can someone tell me how to make this assi...

function that takes a cell array and outputs cell array
Hello I'm sorry if this is a really obvious problem but I am having a hard time finding the specific answer to this on the internet. I am trying to write a function that has a cell array as an input argument and outputs a cell array. I have written the following lines, which at this point should just output the same array as was input: function outTable = coltable(inTable) for i = 1:size(outTable,1) for j = 1:size(outTable,2) outTable{i,j} = inTable{i,j}; end end However, when I try to call the function using the following lines: B = {1 2 3 ; 4 5 6} outGU...

How to sort cell array of cell arrays by inner value
I have a 1 x 500 cell array where each cell is a 1 x 4 cell array. The inner 1 x 4 cell array has a double numeric value in the 4th cell. I would like to sort the 500 cells by this numeric value. What is the best way to do this? Thanks In article <1191983851.468137.61110@r29g2000hsg.googlegroups.com>, G.A.M. <x0Zero@gmail.com> wrote: >I have a 1 x 500 cell array where each cell is a 1 x 4 cell array. The >inner 1 x 4 cell array has a double numeric value in the 4th cell. I >would like to sort the 500 cells by this numeric value. What is the >best way to do this? Thank...