cell-array

Matlab - Why ismember does not work? [closed]

社会主义新天地 提交于 2019-12-13 11:27:37
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 years ago . I have a cell vector with different & redundant company names. And a list of interesting companies. I try to figure out, where in the big matrix the interesting companies appear. I am interested in all appearances. My Code for some reason does not work. the ismember returns always an error. Comps =

Pad cell array with whitespace and rearrange

喜欢而已 提交于 2019-12-13 08:31:34
问题 I have a 2D cell-array ( A = 2x3 ) containing numerical vectors of unequal length, in this form: 1x3 1x4 1x2 1x7 1x8 1x3 *Size of A (in both dimensions) can be variable I want to pad each vector with whitespace {' '} to equalise their lengths to lens = max(max(cellfun('length',A))) ;- in this case, all vectors will become 1x8 in size - and then subsequently rearrange the cell array into this form so that it can be converted to a columnar table using cell2table (using sample data): 4 1 2 1 3 4

Create new variable based on existing columns of a cell in Matlab

时光总嘲笑我的痴心妄想 提交于 2019-12-12 20:26:24
问题 I have a cell-array with 600 000 rows and 5 columns. In the following example I only present 3 different codes and a period of 5 years. Input: c1 c2 c3 c4 c5 1 2006 20060425 559 'IA' 1 2007 20070129 559 'LO' 1 2007 20070826 559 'VC' 1 2008 20080825 34 'VP' 1 2009 20090116 34 'ZO' 4 2007 20070725 42 'OI' 4 2008 20080712 42 'TF' 4 2008 20080428 42 'XU' 11 2007 20070730 118 'AM' 11 2008 20080912 118 'HK' 11 2009 20090318 2 'VT' 11 2010 20100121 2 'ZZ' I would like to obtain a new variable that

save a cell array in matlab as .xlsx or .csv file

喜欢而已 提交于 2019-12-12 18:58:32
问题 I have a cell array myFile 637x16. The first row of the cell array is made of strings, because they will be the columns' labels in the .xlsx/.csv file. From the second row on, the cell array is made of some columns with strings, and some columns with numbers. I would like to export this cell array as a .xlsx or .csv file. Here is an example of what I have: 'subject' 'PeakA' 'PeakL' 'number' 'epoch' 'code' 'type' 'latency' 'nitem' 'condition' 'ia' 'cover' 'variety' 'init_index' 'init_time'

Place equal elements in cell array

旧街凉风 提交于 2019-12-12 05:24:56
问题 I have an array. I sorted it, so I have sorted array and indeces of sorted elements in the initial array. Fo example, from [4 5 4 4 4 4 5 4] I got [4 4 4 4 4 4 5 5] and [1 3 4 5 6 8 2 7] . How to place recieved indeces in a cell array, so that in one cell will be indeces of equal elements? For my example, it will be: {1 3 4 5 6 8} , {2 7} . I'm searching for non-loop way to solve it. 回答1: Use accumarray: x = [4 5 4 4 4 4 5 4]; %// data [~, ~, jj] = unique(x); result = accumarray(jj(:), 1

Using loop instead of arrayfun in matlab

浪子不回头ぞ 提交于 2019-12-12 03:38:01
问题 I have created 3d Cell array "mycell" of size 1x100x19. val(:,:,1) = Columns 1 through 3 {3x1 cell} {3x1 cell} {3x1 cell} Columns 4 through 6 {3x1 cell} {3x1 cell} {3x1 cell} Columns 7 through 13 [] [] [] [] [] [] []..... val(:,:,2) = Columns 1 through 7 [] [] [] [] [] [] [] Columns 8 through 13 {3x1 cell} [] [] [] [] []...... and so on till mycell(:,:,19). As I cannot delete empty rows or colums, I concatenate using arrayfun like this: mycell = arrayfun(@(x)cat(2, mycell{:,:,x}), 1:size

Any other approach for Fasters implementation - matlab cell array

孤街醉人 提交于 2019-12-12 02:53:24
问题 I have an image; I am running a loop over it and creating a cell array. But the process for all the values is very slow. Is it any way possible to fasten the process? Or any other way to do this faster? Any help would be appreciated. [a,b] = size(depth); for i=1:a % a = 1024 for j=1:b %b = 1360 if isfinite(depth(i,j)) segId = (label(i,j)); if (segId > 0) mycell{1,idx,segId} = {i,j,depth(i,j)}; idx=idx+1; end end end end 回答1: Instead of updating the size of mycell each interaction, create the

How to separate data from nested cells?

别等时光非礼了梦想. 提交于 2019-12-11 08:28:14
问题 I have a nested cell as given below A= {1x12 cell} {1x12 cell} {1x12 cell} {1x12 cell} {1x12 cell} I had tried A{:} for getting the data in the above cells and I obtain it as below ans = Columns 1 through 12 '1' '0' '1' '0' '1' '0' '0' '1' '1' '1' '1' '1' ans = Columns 1 through 12 '1' '1' '0' '1' '1' '1' '1' '0' '1' '1' '0' '0' ans = Columns 1 through 12 '0' '1' '1' '1' '0' '0' '0' '0' '1' '1' '0' '0' ans = Columns 1 through 12 '1' '1' '1' '1' '0' '1' '1' '0' '0' '0' '0' '1' ans = Columns 1

Adding 0's to cell array such that each column contains an equal number of entries - MATLAB

纵然是瞬间 提交于 2019-12-11 07:17:22
问题 I have a 16x100 (varies in size) cell array and I would like to extract each of it's columns into a column of a matrix. When each column of the cell array contains an identical number of entries I can use: elem = numel([dist{:,1}]); repeat = size(dist,2); data = zeros(elem,repeat); for k=1:repeat results(:,k) = [dist{:,k}]'; end However there are some instances where there are not an equal number thus it returns the error: Subscripted assignment dimension mismatch. What is the best way around

separating cell array into several columns MATLAB

拥有回忆 提交于 2019-12-11 05:36:30
问题 I have a cell array with one column. Each row consists of only one column. Each cell consist of a String. How can I separate the content of one column in cell array into several columns by separating the string based on space. Each string has different length. Example: cellArrayM= { 'hh pp' 'my 2 ewr 3234 csdf' 'input l 34' 'output K 99 100' } result={ 'hh' 'pp' [] [] [] 'my' '2' 'ewr' '3234' 'csdf' 'input' 'l' '34' [] [] 'output' 'k' '99' '100' [] } 回答1: You can do it this way: x = cellfun(@