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
2 answers

Delete the Whole Row and Merge The Next Row in a matrix

I have a Matrix A = '30' 'X' '@NA' '15' 'Y' [231.001] '00' 'Y' [21.110] '20' 'W' '@NA' '55' 'X' [9.001] '10' 'X' [11.211] >>whos A Name Size Bytes Class Attributes aaa 6x3 226 cell …
user1532230
  • 157
  • 1
  • 2
  • 7
0
votes
1 answer

For loop for a structure with combinations

I want to create a target vector. In which I am having some problems. What I want is all the combinations of 3's of my 18 objects from T into Target. But It is unable to produce that combination. It is working for each combination individually but…
0
votes
2 answers

Array of Cells to store cells, without warning

I'm reading in a file(line by line), and returning it as a <1x175 cell>. It's a big file with big computations so I split it into pieces. I understand preallocating will speed up my code, so I made an array to store my data from the file.…
Riley
  • 23
  • 1
  • 1
  • 4
0
votes
2 answers

select entries and put in a matrix without loop

I have the following: b = [1x4 double] [1x4 double] [1x4 double] [1x4 double] [1x4 double] [1x4 double] [1x4 double] [1x4 double] [1x4 double] [1x4 double] whose dimensions are variable. b{1} ans = 0 0 0 …
pac
  • 291
  • 9
  • 19
0
votes
1 answer

display all elements in a nested cell array (with character entries)

I have the following: a = {1x1 cell} {1x1 cell} {1x1 cell} {1x1 cell} where: a{:} ans = 'a' ans = 'a' ans = 'c' ans = 'a' I want to have the characters: a a c a Since I need the characters to print using…
pac
  • 291
  • 9
  • 19
-1
votes
2 answers

Matlab - Accessing Table fields from a table in cell array

I have problems accessing a column from a table in a cell array. I have a matlab function looking like this: function [tables, rthTables, iGateTables, lastValueTables] = dataEinlesen(~, tcoFiles) tables = cell(4,4); ... for ch …
goldarm5
  • 49
  • 8
-1
votes
1 answer

Coming up with Algorithm

I have a Matlab array of variable size of zeros and a list of characters in a cell array. cell array: {'0000'} {'0011'} I want to place -1 in the array for each 0 bit and place 1 for 1 bit. example: -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 …
user14149198
-1
votes
1 answer

How to convert the elements of a cell array from double to char?

So , i have a cell array(1x5 cell) like this: {[1111] [1111] [1010] [1000] [1011]} the elements inside the cell array are type of double , but i want them to be type of char like this : {'1111' '1111' '1010' '1000' '1011'} i tried to convert them…
-1
votes
2 answers

How to access files of a specific file extension from a cell array on MATLAB

I'm trying to access all of the files with a certain file extension from a cell array I have created on MATLAB, but I'm unsure how to do this. Furthermore, I need to be able to make this a variable input. ie so that when I call my function, I can…
-1
votes
2 answers

Not enough input arguments for CDF

I am trying to plot a CDF for my data, but I get the following error message: Error using cdf (line 69) Not enough input arguments My code: data =cell(1,5); for j=1:length(container)-7 data{j} = some_values; cdfplot(data) So data…
CroatiaHR
  • 615
  • 6
  • 24
-1
votes
2 answers

Enumerating combinations of cells

Say I have 3 cells: M1={ [1,1,1], [2,2,2] } M2={ [3,3], [4,4] } M3={ [5], [6] } I want to take every element in M1, combine it with every element of M2, combine that with every element of M3, ect. For the input above, I would like to produce one…
Frank
  • 952
  • 1
  • 9
  • 23
-1
votes
1 answer

Associate two different variables in a cell array

Let's say I have a cell c_infos <1x313 cell>, that contains (among others) a name associated to a node_ID. c_infos{1,i}.node_ID and c_infos{1,i}.name. I want to create a matrix that for each node_ID, we do have all the associated names. I started…
ssjss7
  • 1
  • 4
-1
votes
1 answer

how to calculate mean across the elements of a cellarray in matlab?

I have a cellarray A of dimension 64x8 with elements in the following dimension, 520x1 double 520x1 double 520x1 double 520x1 double 520x1 double 520x1 double 520x1 double 520x1 double 520x1 double 520x1 double 520x1…
-1
votes
3 answers

How to apply function to each cell in a cell array which contains 3D Matrix in matlab?

I have a cell array A, of dimension say 1x8 and each cell consist of 10x13xNmatirx(numerical values). Example: 10x13x91 double 10x13x91 double 10x13x91 double 10x13x91 double 10x13x91 double 10x13x91 double 10x13x91 double 10x13x91 double now i…
-1
votes
1 answer

how to insert values in to a multi dimensional cell array in matlab?

I have a cell array defined as A = cell(i,8); say i = 4. now i am trying to fill up the 4 x 8 cell array with a function present inside the loop. Say, A = cell(i,8); for index=1:8 A{i,index} = zeros(C{i}, D{i}, E{i}); end where, the values of…