The correct words are not coming to my mouth as yet so please tell what I should have asked to make the question clear.
I have a cell array (1x12) with each cell having the size (65536x1). I want to have a matrix which has the dimensions (65536x12). In short, I want to convert (1x12) cell, with each cell having (65536x1) values, to a matrix with (65536x12) values.
example
I want to do above programmatically using Matlab but couldn't find any solution. (probably because I am not searching using correct words).
Try cell2mat
output = cell2mat(inputImagesCell)
You also misunderstood what a "cell array" is, edited your question, maybe it is clearer now. A cell array is an array of cells. inputImagesCell is a cell array containing 12 cells, consisting of a 65536x1 numeric matrix each. And you want to concatenate all cells to one matrix.
Related
I began making a sudoku game in go, and I have made it so that it puts random numbers from 1 to 9 in each cell in a sudoku board. But in sudoku, you can't have a duplicate cell horizontally and vertically from the cell.
I have seen ways of removing duplicates from a regular array, but the sudoku board is a 2D array.
(P.S: please don't include type inferring in the answers, I find it hard to read)
I'm trying to delete multiple consecutive and non-consecutive columns from a 80-column, 1-row cell array mycells. My question is: what's the correct indexing of a vector of columns in Matlab?
What I tried to do is: mycells(1,[4:6,8,9]) = [] in an attempt to remove columns 4 to 6, column 8 and 9. But I get the error: A null assignment can have only one non-colon index.
Use a colon for the first index. That way only the 2nd index is "non-colon". E.g.,
mycells(:,[4:6,8,9]) = []
MATLAB could have been smart enough to recognize that when there is only one row the 1 and : amount to the same thing and you will still get a rectangular array result, but it isn't.
Before getting the above VERY VERY HELPFUL AND MUCH SIMPLER answers, I ended up doing something more convoluted. As it worked in my case, I'll post it here for anyone in future:
So, I had a cell array vector, of which I wanted to drop specific cells. I created another cell array of the ones I wanted to remove:
remcols = mycells(1,[4:6,8,9])
Then I used the bellow function to overwrite onto mycells only those cells which are different between remcols and mycells (these were actually the cells I wanted to keep from mycells):
mycells = setdiff(mycells,remcols)
This is not neat at all but hopefully serves the purpose of someone somewhere in the world.
I have a list of data that can be seen in this example:
https://docs.google.com/spreadsheets/d/1bRiupsmjfDRE9AgcM_5KJKAyxYKpQiMuyAGSoGaZYN0/edit?usp=sharing
Range A:B is the given data
Range D:E is the desired result
It is very easy to solve it without array formula. But Is there any array formula that can work it out? I need array formula so that i dont have to drag again and again when the data is added below.
use:
=INDEX({A:A, IF(A:A="",, VLOOKUP(ROW(B:B),
IF(B:B<>"", {ROW(B:B), B:B}), 2))})
For column B, put in C1
=ArrayFormula(lookup(row(B:B),row(B:B)/if(B:B<>"",1,0),B:B))
I am new to matlab. I have one question about datatypes.
I have an array of the cell array type. In the variables window it shows me it as 190x1 double.
I have two questions.
What is the purpose of the cell array type if there is the matrix type ?
How to append another similar array to the column of an existing array. For example I have two arrays 190x1 double I wan't a new array to be 380x1 double
I would be grateful for any help.
Thanks
I'd encourage you to browse the documentation for cell arrays. One of the most common uses as it states is mixed size or mixed type data...among other uses.
Cell arrays commonly contain either lists of text strings,
combinations of text and numbers, or numeric arrays of different
sizes.
To append two arrays you could do this. It will place the two vectors end to end.
X=ones(190,1);
X =[X; X];
I have created a function which takes vectors for input variables and returns a cell array for each set of inputs. The final output variable (out) seems to consist of a 2x1 cell containing two 1x5 cells. I have provided a screenshot of this below:
I am just trying to figure out how to flatten the cell array (out) to be a 2x5 cell array.
One way to achieve that would be -
vertcat(cell_array1{:})
If your cell has unequal number of elements in each row , maybe this might work better
vector=[cell_array{:}]