Combine Array from different cell
This is called concatenation. See the documentation of the function CAT. Matlab allows you to concatenate a bunch of column vec...

circa un mese ago | 0

how to make a column vector with evenly spaced entries with different coefficients
A simple one-liner: y = 3 ; k = 4 ; ycoeff(k:k:(k*k), 1) = (-k:-1)*y

circa un mese ago | 0

Mathematical computation for ordering matrices
You can sort the values according to the second column using sortrows. Something along these lines might work for you: centers ...

circa un mese ago | 0

| accepted

Concatenating a 3D matrix in the 3rd dimension when some cells are empty
B = cat(1,A{1,1,1,:}) % N-by-2 array

circa 2 mesi ago | 0

How can I make each cell array consistent in length?
If you make them the same length, you can also store them in a matrix. In that case, my PADCAT function is your friend :-) C = ...

circa 2 mesi ago | 1

Creating a table in matlab based on 2 variables and a for loop if statement.
This creates your table N = 11 ; % 10 timestamps time = 0:N-1 ; x = [4 3 1 4 2] ; y = [1 2 3 1 4] ; Z = repmat(y, N, 1) fo...

circa 2 mesi ago | 0

organising large sets of data into a irregular matrix
You can use cell arrays for this. A=[ 32 7.83425 32 8.0074 5 8.01005 5 8.0119 5 8.10775 19 8.1082 ...

circa 2 mesi ago | 0

| accepted

frequency of 2D matrix in 3D matrix
Convert the 3D N-by-M-by-Z matrix into a 2D Z-by-(N*M) matrix and use unique with the rows option on that. An example: M3D = ca...

circa 2 mesi ago | 0

How to generate data
I suggest you read parts of the starters manual and the help, and start exploring matlab :-) help linspace help colon x = 1:2...

circa 2 mesi ago | 0

Work with a data set to compute std
Step 1 - Write a function that calculates the correlation between two vectors X and Y with equal lengths, using the formula you ...

circa 2 mesi ago | 0

Finding the first and the last elements of consecutive numbers and combining them with a semi colon.
Using diff and logical indexing, this turns out to be quite simple: outliers = [1 2 3 4 5 10 20 21 22 23]; TF = diff(outliers)...

circa 2 mesi ago | 2

Split vector every time data changes from 2 to 1
Another approach: A = [1 2 1 1 2 1 2 2 1 1 1 2 2 2 1 1 1 2].' % data C = accumarray(cumsum([0 ; diff(A)==-1])+1, A, [], @(x) {...

circa 2 mesi ago | 1

Plotting a circle always around a moving point
Adapted from the help of animatedline: numpoints = 10000; x = linspace(0,4*pi,numpoints); y = sin(x); pc = [-.1 -.1 .2 ...

circa 2 mesi ago | 0

Issues with function ismember
Comparing floating point numbers is always tricky! Two number may look the same for you, but could still be slightly different f...

circa 2 mesi ago | 1

| accepted

Submitted

randp
pseudorandom integers from a specified discrete distribution

How to find a combination like this
Computationally less efficient, and mathematically less beautiful as Walters' snippet, but more matlab-ish in style: N = 4 ; C...

circa 2 mesi ago | 0

How to compute fast?
Some suggestions: replace mean(A,B) by (A+B)/2 you can have j run from i to length(K1), since everything seems symmetric (unle...

circa 2 mesi ago | 0

How can I check if a specific set of numbers are present in my array?
I cannot resist to put the "simple" matlab version here. Note that this problem is closely related to Run-Length Encoding scheme...

circa 2 mesi ago | 3

Submitted

nchoose2
all combinations of two elements

Fastest pairwise row sums
% An old-school 20th century indexing trick: A = randi(9,3,2) B = 100*randi(9,4,2) [ia, ib] = ndgrid(1:size(A,1),1:size(B,1...

circa 2 mesi ago | 0

Quickly create a vector of ones and zeros
N = 10 % final length of NewVec pos1 = 3 % start index of the 1's n1 = 4 % number of 1's % one-liner. NewVec should...

circa 2 mesi ago | 0

how to load values of two matrices into one matrix?
Many roads to Rome, which all learn you about using transpose, reshape, concatention, and/or clever indexing H1 = reshape([A B]...

circa 2 mesi ago | 0

Compute difference between rows
I do not understand where A and B come from but this gives the differences between all combinations of 2 rows of the matrix M. ...

circa 2 mesi ago | 0

| accepted

How to extract sequential submatrices
Do not create 13 different variables, but store the result in 13 cells of a cell array, by applying MAT2CELL

circa 2 mesi ago | 0

Converting a 4d vector to 2d vector
Y = randi(10,1,1,3,4) Y2 = squeeze(Y) % remove singleton dimensions help squeeze

2 mesi ago | 0

| accepted

choose 2 random unique element inside cell
If I understand you correctly, the final output should have 8 unique numbers, in four groups of two, where the numbers in each g...

2 mesi ago | 0

Deletion of array value in both positions of separate arrays dependent upon the range of one array
A few remarks: 1. what if result is exactly +3 or -3? (you might want to use <= rather than <) 2. replace the two ELSE...

2 mesi ago | 0

How to increment from 1 to 0.0000000001 (9 zeros) in 11 rows, 1 column (divide by 10 each time)
format long % for display purposes only v = 10.^(0:-1:-10).'

2 mesi ago | 1