"Flattening" a cell array - arrays

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{:}]

Related

Fill Empty Cells With The Same Value as Previous Cell in Google Sheet (Array Formula)

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))

Excel - Passing a cell containing an array formula as input to a function in another cell

I was wondering if in excel there was a way to do this:
In cell A1 write an array function (e.g.INDEX(some_array,r_n,0) where some_array is a square NxM array and r_n is the row number, commited using Ctrl+Space+Enter)
In cell B2 calculate the i-th percentile of array in cell A1. I would
like to write something like PERCENTILE.INC(A1,i/100), which, alas, does not work, returning the first element of the array in A1.
Currrently I'm passing the formula in A1 to percentile, but it's a bit cumbersome.
Thanks in advance
Currently there seems to exist a functionality for this, in case someone stumbles upon the same problem as I did.
Making use of the spill range functionality, you just need to append the '#' char to the address of the first cell of the spill range you want to use as part of some function, e.g. 'A1#'.

Output all array values to a cell

I'm having a bit of trouble dealing with the output of array formulas in Excel, e.g.:
{=IF(B3:D3>=4;"Something";"")}
What I want to achieve with this snippet is to print "Something" in the target cell if one value of the array is greater or equal to 4. If we assume our array is {1,1,4} the result should be {"","","Something"}, but Excel will only print the first value of the array resulting in a blank cell.
Is there an easy way to make this work?
Also, how do I compare an array against a "static" array? Something like:
Pseudocode
{=IF(B3:D3={1,1,1};"Every value is 1";"")}
Purpose being to determine if every value in B3:D3 is 1 then print something to the target cell.
Is it possible to enter an array/list like {1,1,1} directly into the formula?
I've Googled to no avail, could only find solutions where the "conditional" array was defined in an array somewhere on the sheet or just chaining the value checking with AND statements.
Try this formula:
=IF(COUNTIF($B$3:$D$3,1)=COLUMNS($B$3:$D$3),"Every value is 1","")
First part can be done like this for a cell range:
=IF(MAX(B3:D3)>=4, "Something", "")
or for static array:
=IF(MAX({1,2,3,4})>=4, "Something", "")
Second part to check matching arrays must be done by pressing Ctrl_Shift_Enter when entering the formula:
IF(MIN((B3:D3={8,5,8})+0)>0, "Matches!!", "NOT matching")

Matlab: concatenate all cells to one matrix

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.

Problem with assigning elements of a class array to individual variables in MATLAB

This is a bit of a duplicate of this question, this question, and this question, however those solutions don't work, so I'm asking mine.
I've got an array of locally defined classes and I'd like to assign it to multiple, individual variables. This pattern doesn't work:
%a is 2x1 of MyClass
temp = mat2cell(a);
[x,y] = temp{:};
%throws:
??? Insufficient number of outputs from right hand side of equal sign to satisfy assignment.
Because temp is a single cell, with my 2x1 array in one cell, rather than a 2x1 cell array with one element of each of my original array in one cell.
Any ideas?
You should use the function NUM2CELL instead of the function MAT2CELL in order to place each element of your array a in a separate cell of your cell array temp.
Using MAT2CELL with just one input is equivalent to doing temp = {a};, and in my version of MATLAB (R2009a) I actually get this warning:
>> temp = mat2cell(a);
Warning: Single input behavior is obsolete and will be removed in a
future release of MATLAB. Use C={X} instead.
> In mat2cell at 54

Resources