# cell array

• ## to find mean square error of two cell arrays of different sizes2018-05-15

I have two cell arrays. One is 'trans_blk' of size <232324x1> consists of cells of size <8x8> and another 'ca' is of size <1024x1> consists of cells of size <8x8>. I want to compute mean square error (MSE) for each cell of 'ca' wit

Tags: matlab, block, mse, cell array
• ## Read specific character from cell-array of string2017-05-21

I have an cell-array of dimensions 1x6 like this: A = {'25_2.mat','25_3.mat','25_4.mat','25_5.mat','25_6.mat','25_7.mat'}; I want to read for example from the A{1} , the number after the '_' i.e 2 for my example --------------Solutions------------- U

Tags: matlab, cell array
• ## How to use the 'if' statement in matlab?2015-01-29

I have a cell array of size 5x5 as below B= 00 10 11 10 11 01 01 01 01 11 10 00 01 00 01 10 10 01 01 11 10 10 10 00 10 And two column vectors S1= 21 23 28 25 43 S2= 96 85 78 65 76 I want to create a new cell array of the same size as B say 5x5 such t

• ## matlab char array to cell array 2014-09-01

This question already has an answer here: Matlab array of char to string 2 answers say I have an array of chars which looks like.... hello hillo hello and I would like to convert them to a cell array which would be the same as... A = {'hello';'hillo'

Tags: matlab, matrix, char, cell array
• ## Loss of precision when using cell2mat() in Matlab2014-04-29

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 = cell2mat(mycell) mym

Tags: matlab, precision, cell array
• ## Saving fgets into an array or text file with a time stamp from a while loop2014-03-25

I am using MATLAB to get output from a tracking device for gloves. I basically have: read = fgets(tracker); tic k = 1; while ischar(read) read = fgets(tracker); toc k = k+1; end I want to take 'read', which is a string, and save it with a time stamp

Tags: matlab, text, fgets, while loop, cell array
• ## How to concatenate arrays from cell arrays in Matlab2014-03-05

I am new to Matlab and was trying to concatenate array from cell arrays. I have done it as shown below. S = load('input_file.mat'); c = struct2cell(S); v = cell2mat(c(1,1)); temp = v(1:500,1:600); v = cell2mat(c(3,1)); temp1 = v(1:500,1:600); v = cel

Tags: matlab, arrays, cell array
• ## Appending string column to number column2014-02-26

How to append a column of strings to a column of numbers in MATLAB? For example, I have the string column wrds and the number column occurs wrds={'the' 'of' 'to' 'and'}'; occurs=[103 89 55 20]'; And I want to put them side by side so that they displa

• ## How to determine if all cell array elements are nonzero or true? Or: What is the cell array equivalent for "all"?2013-10-14

I'm looking for a fast way to evaluate whether any element of a cell array contains the logical value false. For matrix arrays there is the convenient function all which is not working for cells. I have a hard time to implement the same function for

Tags: matlab, cell array
• ## How to judge the data in a cell is 'invalid'2013-09-25

'' [ 2281] [ 2520] [8] '' [] [] '' Like above data in my cell array. How do I determine the second row is invalid? I tried isempty(), but the result is not optimal. --------------Solutions------------- Use cellfun and all along columns with isempty a

Tags: matlab, cell array
• ## display all elements in a nested cell array (with integer entries)2012-04-14

This is related to the post display all elements in a nested cell array (with character entries) with a change where entries are characters. A new question was asked for clarity. Now : a = {1x10 cell} {1x10 cell} {1x10 cell} {1x10 cell} a{:}= ans = [

Tags: matlab, cell array
• ## display all elements in a nested cell array (with character entries)2012-04-13

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 fprintf fprintf won't accept a{:} If I do a{1}

Tags: matlab, cell array
• ## producing cell array2012-02-09

I want to produce a cell array as below in matlab: P= {100;010;000;000;001} {100;000;010;000;001} {100;000;000;010;001} {000;100;010;000;001} {000;100;000;010;001} {000;000;100;010;001} where P= {5x3 cell} {5x3 cell} {5x3 cell} {5x3 cell} {5x3 cell}

Tags: matlab, cell array
• ## Difference between accessing cell elements using {} and () (curly braces vs. parentheses)2012-01-29

What is the difference between accessing elements in a cell array using parentheses (()) and curly braces ({})? For example, I tried to use cell{4} = [] and cell(4) = []. In the first case it set the 4th element to [], but in the second case it wiped

Tags: matlab, cell array
• ## Parsing string of a cell to cell2011-12-28

I have the following string in MATLAB: contents = '{'aa' 'bb' 'cc' 'dd'}' I need to get the 1x4 cell-array inside it, like: mycell = {'aa' 'bb' 'cc' 'dd'} How would you do it? Is there a quicker way than parsing it? --------------Solutions-----------

Tags: string, matlab, cell array
• ## How do you sort and efficiently find elements in a cell array (of strings) in Octave?2011-11-22

Is there built-in functionality for this? --------------Solutions------------- Yes check this: http://www.obihiro.ac.jp/~suzukim/masuda/octave/html3/octave_36.html#SEC75 a = ["hello"; "world"]; c = cellstr (a) ⇒ c = { [1,1] = hello [2,1] = world }

Tags: search, sorting, find, octave, cell array
• ## How to create cell-array in MATLAB and initialize all elements to the same object?2011-11-19

I have a matrix (call it X) that is initialized to say zero(3). I want to change the code so that X is a cell array of size (say) (3,1) and initialize each element to zero(3). I can do it with a loop but is there a better way? X = cell(3,1); for ii=1

• ## How to write this in an elegant way (cell arrays and structs in MATLAB)2011-11-09

I would like to plot connected points in MATLAB. My connected points come from connecting objects of "stats", where each "stat" comes from a BW regionprops struct. The code I have written works, but it suffers from a lot of "ugliness", which I couldn

• ## How to search for a string in cell array in MATLAB?2011-11-09

Let's say I have the cell array strs = {'HA' 'KU' 'LA' 'MA' 'TATA'} What should I do if I want to find the index of 'KU'? --------------Solutions------------- I guess the following code could do the trick: strs = {'HA' 'KU' 'LA' 'MA' 'TATA'} ind=find

Tags: string, matlab, cell array
• ## Non-empty size information for cell arrays2011-11-03

In MATLAB I would like to keep a list of polylines - containing vertices (x,y) - in a container and I thought the best idea is to use cell arrays for this task. Each line would be represented in a row in a cell array, with vertices (x,y) being the el

Tags: matlab, arrays, list, polyline, cell array