Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Filter by
Sorted by
Tagged with
5 votes
2 answers
91 views

How to pass cell indexing as an input argument to a function, such that cell inside the function can use the indexing directly?

I am wondering if we can pass cell indexing as an input argument to a function, such that a cell inside the function can parse it. For example, given a cell like x = num2cell(reshape(1:24, [2,3,4])), ...
ThomasIsCoding's user avatar
2 votes
2 answers
67 views

How to effciently add a field of the same repeated value to a struct array

I have a non-scalar struct array. For example S=struct; S(1).f1='a'; S(2).f1='b'; How do I add a field .f2 to S for the same value 1 efficiently? such that S becomes a struct with S(1).f2=1; S(2).f2=...
Argyll's user avatar
  • 10.1k
2 votes
3 answers
92 views

how to sum cells/ struct in matlab

I am trying to add vertically the lists of a database like DB (see below) contained in a cell. DB={ {[11 12]} {[13 14]} {[15 16]} {[17 18]} {[19 20]}; {[21 22]} {[23 24]} {[25 26]} {[27 28]} {[...
jeanjacquesvivde's user avatar
1 vote
1 answer
462 views

<Missing> Values in Cell Arrays Created from Matlab readcell()

I am uploading data from an Excel file which was provided in a specific format, for which a minimum reproducible example is shown below: I am trying to save each column into an array, using the ...
AmericanJael's user avatar
2 votes
2 answers
333 views

extracting a row from a cell-array

I have a cell-array in which contains some information on how to process some data, like the following: C = [ {{1 2 3} true 0 0 5 false}; ... {{2 3 4} true 0 0 3 false} ... ] How can I ...
Xoriun's user avatar
  • 180
1 vote
2 answers
173 views

Matlab cellfun, how to apply indexing to strings on each element?

I'm having trouble indexing into strings contained in a cell array using the cellfun function. I have a cell array with strings of various contents, and I'm trying to extract the numbers between the ...
Sanjo's user avatar
  • 195
0 votes
1 answer
29 views

Populate Every other Element of Array with Function Handle MATLAB

I have the following function: function F = farray (f,N) F = {@(t) zeros(N,1)}; for i=1:N if mod(i,2)==0 F{i}=f(t); end end F = cell2mat(F); end f is a function ...
Jonathan Frutschy's user avatar
0 votes
1 answer
108 views

transferring data between python and MATLAB: how to deal with list of lists?

I did this post in Mathwork as well. But I guess I will benefit also asking it here. Here is a link to my mathwork community post. https://www.mathworks.com/matlabcentral/answers/2104821-load-save-...
Lily's user avatar
  • 1
1 vote
1 answer
61 views

Convert Cell Array of Symbolic Functions to Double Array of Symbolic Functions MATLAB

I have the following: syms x; F = {3*x,2*x,x}; I would like to make F the following array G: G = [3*x,2*x,x]; To do this, I have tried this: G = double(F); and this: G = double([F{:}]).'; Neither ...
Jonathan Frutschy's user avatar
0 votes
2 answers
116 views

Is there a functional form in Matlab to get the same result as A{:}?

I understand this is a classic question and some aspects of it have been answered before, for instance here: How can I index a MATLAB array returned by a function without first assigning it to a local ...
M-G-K's user avatar
  • 11
2 votes
2 answers
120 views

Extractig data from cell array

In this MWE, I generate dis (x, y, z displacements for nodes and increments), I then need to extract separately the displacements clear k=0; % ignore following, this is just to buils dis for node=1:20 ...
user2260180's user avatar
1 vote
0 answers
101 views

Pass Function Handle to ODE45 in Matrix

I'm trying to use ode45 to predict the behavior of the following system: I'm getting the following error with my Force matrix F: Since the forcing function changes with time, I made it a function ...
Jonathan Frutschy's user avatar
3 votes
2 answers
118 views

How to fix this error extracting empty structure fields from a cell array when using cellfun()

I have a cell array in Matlab, with each cell representing a financial transaction as a structure object (the cell array is earlier imported from a json file). Here is an example to create a test set ...
teeeeee's user avatar
  • 785
0 votes
1 answer
53 views

How to create parametrized matrix

I would like to create parametrized matrix with given relationship between arguments like this: B= @(A) [1*A(1), 2*A(2), 3*A(3), 4*A(4)]; But matrix is huge and cannot be created by constant ...
Ales100's user avatar
  • 185
0 votes
1 answer
44 views

Creating a cell array with 2 rows; 1st row for characters and 2nd for their related 5 bits using dec2bin function in matlab

I am trying to make a 2*32 cell array in matlab. The first row are the characters 'a' to 'z' , space, period, comma, exclamation Point, semicolon and quotation (32 chars). The second row must be '...
Setayesh's user avatar
0 votes
2 answers
2k views

Why does cell2mat convert a cell array into a matrix of characters, instead of a matrix of cell contents?

I have this cell array >> FooCellArray FooCellArray = 1×7 cell array Columns 1 through 4 {'Foo1'} {'Foo2'} {'Foo3'} {'Foo4'} Columns 5 through 7 {'Foo5'} {'Foo6'} ...
KMC's user avatar
  • 20.1k
2 votes
2 answers
158 views

Deleting consecutive and non-consecutive columns from a cell array in Matlab

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 ...
Orestes_Fox's user avatar
2 votes
1 answer
2k views

MATLAB Search Within a Cell Array of Cells

Setup: I have a 21 x 3 cell array. The first 2 columns are USUALLY strings or char arrays, but could be 1xn cells of strings or char arrays (if there are multiple alternate strings that mean the same ...
Trashman's user avatar
  • 1,665
1 vote
1 answer
160 views

Creating a loop in MATLAB to split up a list of sentences by a delimiter

I want to be able to run a loop through my current code. I have a cell array with 423 cells. Each cell is a long string of smaller strings that I am trying to separate by the delimiter (;) and I want ...
Boo's user avatar
  • 61
2 votes
1 answer
42 views

Removing Measurement Units from Cell Array

I am trying to remove the units out of a column of cell array data i.e.: cArray = time temp 2022-05-10 20:19:43 '167 °F' 2022-05-10 20:19:53 '173 °F' 2022-05-10 20:20:03 '177 °F' ......
Brian's user avatar
  • 41
1 vote
1 answer
4k views

Concatenate cell array in MATLAB

In Matlab you can concatenate arrays by saying: a=[]; a=[a,1]; How do you do something similar with a cell array? a={}; a={a,'asd'}; The code above keeps on nesting cells within cells. I just want ...
berala's user avatar
  • 155
0 votes
2 answers
130 views

Group data in a cell array

I have the following data: Names={A1 A2 B1 B2 C1 C2 C3} Doserate=(2.2 3.4 6.4 3.4 2.3 4.5 7.5) Time=(5 7.8 9 3.5 10.2 5.6 7.8) The order of Doserate and Time is such they correspond to Names. I would ...
Jan's user avatar
  • 67
0 votes
1 answer
60 views

How to store every element of a cell array in a separate folders?

I have a problem assigning and storing data to subfolders. I have one folder let's say a new folder, and I created 6 subfolders based on the size of a cell array. Now I want to save every element of ...
hamed majidian's user avatar
0 votes
1 answer
47 views

Assign same number of elements to the column data based on number of elements (each row) of the other column

I have two column data, where first column contains "Number of Elements" and the second column contains "Stages" data. I want to assign the same number of data elements of "...
Ganesh's user avatar
  • 25
0 votes
2 answers
2k views

How to append an empty array to a cell array

How do you append an empty array to a (non-empty) cell array? For example, starting with c={[1],[2]} desire c={[1],[2],[]} Concatenation would remove the empty array whether it is double, char or ...
Argyll's user avatar
  • 10.1k
1 vote
1 answer
335 views

How to create all permutations of a 2-column cell-array?

I created a cell array of shape m x 2, each element of which is a matrix of shape d x d. For example like this: A = cell(8, 2); for row = 1:8 for col = 1:2 A{row, col} = rand(3, 3); ...
Lancdorr's user avatar
  • 445
1 vote
3 answers
156 views

Matlab: non-integers or numbers below 1 as indices; numbers as field names

Matlab has limitations in terms of how things can be numbered/indexed: Arrays and cell arrays require indices that are natural numbers (with exceptions that are discouraged and not more general). ...
root's user avatar
  • 2,946
1 vote
1 answer
1k views

Using python to create a .mat file with a cell array in it

I'm trying to create a mat file with a cell it it. I tried to apply some solutions I found on the internet but non of them worked. The code I'm wishing to have at the end is something like that: ...
MeatBALL's user avatar
1 vote
3 answers
240 views

Matlab: What's the most efficient approach to parse a large table or cell array with regexp when sometimes there is no match?

I am working with a messy manually maintained "database" that has a column containing a string with name,value pairs. I am trying to parse the entire column with regexp to pull out the ...
skratch's user avatar
  • 33
0 votes
1 answer
108 views

How to convert 1d array of chars from CSV to 2d cell array in Matlab

I have a function I cannot change in Matlab that converts CSV file to a 1d array of chars. This is an example of what it looks like: array_o_chars = ['1' 'd' ',' ' ' 'a' 'r' 'r' 'a' 'y' '\n' 'o' 'f' ',...
mwso's user avatar
  • 128
0 votes
0 answers
310 views

cell2mat produces wrong output size

I have a cell matrix with size 32x32 where each cell is an 8x8 matrix and all values are floats. I use DCT to each 8x8 cell and after that I assign each matrix to another empty cell matrix. So, the ...
mykael's user avatar
  • 21
0 votes
1 answer
1k views

Array values to cells

I have google script for changing text in rows. Problem after text modification is that I do not know how to save array values to cells in second sheet. // Array to cells function ...
Dancul's user avatar
  • 21
0 votes
1 answer
211 views

R equivalent to permuting array dimensions permute(A, dimorder) in Matlab

I am looking for an equivalent of permute(A,dimorder) from Matlab, in order to convert some Matlab code to R. A loop entails a line that looks something like this: x = permute(a{i}(b(i,ii),:,:,:,:,:),[...
Steffen Schwerdtfeger's user avatar
0 votes
1 answer
76 views

python3 - after successfully reading CSV file into 2D Arrary - how to print a single cell by index?

I want to read a CSV File (filled in by temperature sensors) by python3. Reading CSV File into array works fine. Printing a single cell by index fails. Please help for the right line of code. This is ...
Karl's user avatar
  • 51
0 votes
2 answers
332 views

How to assign indexes to a function handle?

I'm trying to approximate the integral of the functions "fun_1" and "fun_2" over the given region. In the case of one single "f" it seems ok. But I want to use a vector &...
Mohammad Sd's user avatar
0 votes
0 answers
213 views

MATLAB Cell Array - Replacing Numbers in Different Columns with Strings

I am working in Matlab. I created a matrix and then a cell array based on that matrix: A = randi([1 5], 5, 5); B = num2cell(A); I want to replace the numbers in B with different strings based on A's ...
K_Sol's user avatar
  • 1
0 votes
1 answer
149 views

counting most commonly used words across thousands of text files using Octave

I've accumulated a list of over 10,000 text files in Octave. I've got a function which cleans up the contents of each files, normalizing things in various ways (lowercase, reducing repeated whitespace,...
S. Imp's user avatar
  • 2,877
0 votes
0 answers
64 views

How can I convert a 2-D cell array to a 3-D cell array in matlab

Each cell is a single element (I'm not storing arrays larger than 1x1 in a cell array... I'm using a cell array to hold both numbers and characters). The cell array is 32x3822x1 and stores information ...
bme-programmer's user avatar
2 votes
2 answers
274 views

Why is the cell array structure in Matlab not behaving well and keep constructing vectors?

Let's say I have two simple vectors; vec1=[1,2,3]; vec2=[4,5,6]; Now I make a cell array from them. cellArray1={vec1,vec2} If I want to create a 2x3 numerical array, it is simple. [vec1;vec2] %or [...
AmirHosein Sadeghimanesh's user avatar
-1 votes
2 answers
1k views

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) ...
goldarm5's user avatar
1 vote
1 answer
123 views

Repmat in Matlab to replicate specific elements

I have the following lines of code where I find an event "41" in my cell array called Events (minimal example of this array included below) and the lines of code allow me to add 8 events ...
Maheen Siddiqui's user avatar
0 votes
1 answer
168 views

Aligning multiple arrays in a cell array by prepending/postpending NaNs

I am trying to align arrays within a cell-array while prepending/postpending NaNs to match the size of arrays like this for example: %Setting up data A = [0.01 0.02 0.03 0.01 0.60 0.90 -1.02]; B = [0....
Likeunknown's user avatar
0 votes
2 answers
200 views

Convert cell string with commas and spaces to vector

I tried to convert the cell x: x(1,:) = {'35,35, ,35'}; x(2,:) = {'40,40,30,40'}; x(3,:) = {'10, , ,'}; to a matrix with: R = cell2mat(cellfun(@str2num,x,'un',0)); but the outcome omits the first ...
Oliver Amundsen's user avatar
0 votes
1 answer
113 views

Pre-Allocating Single Cell's Memory

I am writing a code and would like to know how to pre-allocate the memory for a single cell. I understand that one can easily pre-allocate an array of cells, but this isn't what I'm looking for. My ...
pimler's user avatar
  • 61
0 votes
1 answer
375 views

How to find an matching element (either number or string) in a multi level cell?

I am trying to search a cell of cell arrays for a matching number (for example, 2) or string ('text'). Example for a cell: A = {1 {2; 3};4 {5 'text' 7;8 9 10}}; There is similar question. However, ...
ofey's user avatar
  • 1
0 votes
1 answer
254 views

Removing duplicate strings from a nested cell array

I have a 1x234 cell array called tmp from which I want to delete all duplicates. Some elements of tmp can be: tmp{1, 3} -> 'Ro' tmp{1, 167}{1, 1} -> 'Ro' tmp{1, 167}{1, 2} -> 'CvF' Of the ...
Joesi's user avatar
  • 3
0 votes
2 answers
446 views

Octave: How to assign the right dimensionality to an existing cell array to avoid "error: =: nonconformant arguments (op1 is 2x2x2, op2 is 2x2x2)"?

I am a beginner at Octave, that is why I will share something too obvious for the most. cell_arr = cell(2,2,2); cell_arr(2,2,2) = cell(2,2,2); error: =: nonconformant arguments (op1 is 2x2x2, op2 is ...
questionto42's user avatar
  • 9,924
1 vote
2 answers
1k views

Cell Array String from Matlab to Python

I have a .mat dataset obtained from Matlab that have some data, including an 1920x1 Cell Array String stored as follow: "sample1" "sample2" "sample3" I need to import it ...
marcosautto's user avatar
0 votes
1 answer
237 views

How to extract one column from Matlab matrix?

I have the following code: N = 10; params = cell(N-3,4); step = 1; for i = 3 : N-1 % Calibrate the camera [cameraParams, imagesUsed, estimationErrors] = estimateCameraParameters(...
M_Z's user avatar
  • 201
0 votes
1 answer
160 views

Extracting arrays from array

I am currently working on machine learning, and as so I have an array in which the first column is the data and the second column is the label. Data was originally a cell array from Matlab (Not sure ...
Tim's user avatar
  • 3

1
2 3 4 5
21