Questions tagged [cell-array]

In MATLAB cell arrays are a built-in container class allowing for the storage of different types of data in each "cell" of the array.

A cell array is a data type with indexed data containers called cells, where each cell can contain any type of data. Cell arrays commonly contain either lists of text strings, combinations of text and numbers, or numeric arrays of different sizes.

You can refer to subsets of cells by enclosing indices in smooth parentheses, (). The cell contents can be accessed by indexing with curly braces, {}.

Examples:

>> ca = cell(2, 3);        % create 2-by-3 cell array with empty cells
>> ca{1, 1} = 3;           % store a double scalar in one cell
>> ca{1, 2} = rand(3, 4);  % store an entire matrix into a cell
>> ca{1, 3} = 'will you look at that, a string in a cell!';
>> ca{2, 1} = @mean;       % a function handle can also be stored in a cell
>> ca{2, 3} = uint32(45);  % store a uint32 scalar
>> ca(1, 1:3)   % Get a subset of cells (first row)

ans =

  1×3 cell array

    [3]    [3×4 double]    'will you look at that, a string in a cell!'

>> ca{1, 2}     % Get the contents of a cell

ans =

    0.8147    0.9134    0.2785    0.9649
    0.9058    0.6324    0.5469    0.1576
    0.1270    0.0975    0.9575    0.9706
1035 questions
0
votes
3 answers

Matlab: how to write cell array of matrices to file

i have a cell of several matrices (all double and with the same dimension) my_cell = [172x15 double] [172x15 double] [172x15 double] [172x15 double] I would to write the matrices on txt file side by side and tabulated, to obtain a…
Mixo
  • 191
  • 13
0
votes
1 answer

MATLAB fprintf printing cell array to text file

I am attempting to use the MATLAB fprintf command to print a delimited table of strings stored in a vector to a text file. Which strings from the vector are chosen and printed depends on a matrix which is constructed in the main while loop of the…
luthier93
  • 60
  • 6
0
votes
1 answer

Concatenate multiple cells

I have a cell called Object that contains 1x24 cells which all have 1 column but have the number of rows ranging from 14 to 16. Some cells, however, are empty. I would like to concatenate these cell into one single cell P with the dimension of 16 x…
A.Rainer
  • 719
  • 5
  • 16
0
votes
3 answers

Deleting values from an element of a cell array

Column 2 of cell array X provides me with the following codes: '00000127' '00010121' '00040486' '00003702' '00010077' '00000002' '00000050' etc … And I only want to have the last numbers (the numbers on the right), for instance like…
user3557054
  • 219
  • 2
  • 11
0
votes
1 answer

select subcells based on a different cell string - matlab

Given the following cell array of strings: a(1) = {{'one', 'two', 'three', 'four'}} a(2) = {{'one', 'two', 'four', 'five'}} a(3) = {{'four', 'five', 'six', 'seven'}} b = {'one', 'two'} is there a way to check whether both strings in b are…
HappyPy
  • 9,839
  • 13
  • 46
  • 68
0
votes
1 answer

How to create cell arrays dynamically

I need to create 10 empty cells: Outlier1, Outlier2,...,Outlier10, each being a different size. Due to the use of a previously existing loop, I'd like to do something like this: for z=1:10 sprintf('Outlier%d',z)=cell(size(R,2),1); end Basically,…
A.Rainer
  • 719
  • 5
  • 16
0
votes
0 answers

logical indexing into cell array to remove rows

I have a cell array and I am looking to remove some of the rows. If a company in my cell array is not in companies_list I would like to remove the row from my cell array. I have tried the below however I get the error message: Function 'subsindex'…
mHelpMe
  • 6,336
  • 24
  • 75
  • 150
0
votes
1 answer

Store words after specific expressions in text file using matlab

I have many text files containing data like this: {'photo': {'people': {'haspeople': 0}, 'dateuploaded': '1264588417', 'originalformat': 'jpg', 'tags': {'tag': [{'machine_tag': 0, 'author': '14988396@N00', 'text': 'bokehlicious', 'raw':…
0
votes
1 answer

MATLAB: how to sort a matrix by a specific column name and also let the row names follow the order?

I am new to MATLAB. I have a data structure named da. I want to sort the first column of da.mat and want to let da.rid and the other columns to follow the rearranged order. da.cid contains the column names and da.rid contains the row IDs. da = …
woodylin
  • 17
  • 4
0
votes
0 answers

Group different Matrices together - cellarray

I was wondering what is the best way to group different matrices together. I have multiple matrices called A1 (of size 9 x 48), A2 (of size 3 x 48), A3, A4 and so on. Each of these matrices are of a different size. I want to group all of these…
0
votes
1 answer

search in the second column of a cell array by the value of the first column

I'm working in MATLAB and I have the following cell array: pippo = 'FSize' [ 10] 'MSize' [ 10] 'rho' [ 997] 'u2' [ 86.2262] 'n' [ 100] 'nimp' [ …
DeltaIV
  • 4,773
  • 12
  • 39
  • 86
0
votes
4 answers

how to remove duplicate matrixes in a cell array?

I have a cell matrix TILER that include some matrix with different sizes. TILER=[22x4 double] [1265x4 double] [58x4 double] [31x4 double] [58x4 double] and we know that some matrixes are duplicate, for example [58x4 double] matrix. how…
Ahmad
  • 73
  • 3
  • 13
0
votes
0 answers

Overcoming "Out of Memory" Errors in MATLAB Distributed Applications

Context: I'm running a job (consisting of 1 to 50 tasks) on a cluster, waiting for it to finish, and then pulling the results using: outputArgs = getAllOutputArguements(myJob); The Problem: The getAllOutputArguements() function is returning a…
0
votes
1 answer

Loss of precision when using cell2mat() in Matlab

Suppose I have a cell array like the following: mycell = [-1.6411e-16 + 1.4863e-19i] [ 0.6450 + 0.6433i] [ 0.6450 + 0.6433i] [-1.6411e-16 + 1.4863e-19i] I want it to be a matrix, so I use the command cell2mat: >> mymatrix =…
baister
  • 283
  • 2
  • 9
0
votes
1 answer

isequal not returning true for element in cell array in MATLAB

any idea why this isn't returning true??? comments01a is a cell array of cells although I'd be perfectly happy converting it to a matrix. However, cell2mat(comments01a) gives its own error that it doesn't support cell arrays containing cell arrays…