Answered
Searching a huge array with a for loop - How to increase speed?
ts = datenum('20130102 00:00:00:000', 'yyyymmdd HH:MM:SS:FFF'); te = datenum('20170731 23:00:00:000', 'yyyymmdd HH:MM:SS:FF...

7 years ago | 0

| accepted

Answered
from a=[1 2 3 4] to b=[1 1 2 2 3 3 4 4]
b = repelem(a,2)

7 years ago | 3

| accepted

Answered
Interpolation of R^3 -> R^3
(*NOTE*: my post is not easily to be followed since the RGB description has been removed.) Assuming RGB5 is (n x 3) first set...

7 years ago | 0

Answered
Index exceeds matrix dimensions.
After read the file type >> size(img) If the third dimension is not 3, it's not RGB image

7 years ago | 1

| accepted

Answered
smooth 2D array and maintain boundaries
One way (bug edited version): <</matlabcentral/answers/uploaded_files/140348/Smooth2D.png>> % Generate fake data A = ...

7 years ago | 1

| accepted

Answered
How to connect two polygons with a perpendicular line? The line doesn't have to be at the actual points, just somewhere on the outer shape connected to the inner shape. I used roipoly to create the polygons.
Apply <https://fr.mathworks.com/matlabcentral/fileexchange/34869-distance2curve this function> with vertexes of one polygonal to...

7 years ago | 0

Answered
Minimize non linear function with undefined vector
I'll save you some headache: the solutions are clearly x = ones(n,1);

7 years ago | 0

Answered
I would like to separate a matrix into different matrices based on a cycle of the first values
A=[1 2 3 1 2 4; 1 1 1 2 2 2]; lgt = diff(find([true,diff(A(1,:),1,2)<0,true])); C = mat2cell(A,size(A,1),lgt); Re...

7 years ago | 2

| accepted

Answered
how can i randomly sample from a matrix and determine the remaining part?
D2=D(setdiff(1:end,c),:) or b = ~logical(accumarray(c(:),1,[size(D,1) 1])); D2 = D(b,:); or b = true([size...

7 years ago | 2

| accepted

Answered
Extrapolating from linear fit
" _Currently, it plots a line over my data. How can I specify the limits of the linear fit (I'd like to extrapolate)._" You g...

7 years ago | 0

Answered
how do i generate coordinates with a set of restrictions?
xyz=rand(10000,3)*4-2; % with in (-2,2) figure plot3(xyz(:,1),xyz(:,2),xyz(:,3),'.')

7 years ago | 0

Answered
allocate values avoiding loop
A=[... 1.0000 1.0000 -1.1471 1.0000 2.0000 -1.0689 2.0000 1.0000 -0.8095 ...

7 years ago | 1

Answered
Verifying a region is covered using circle covering
One way to check is to build the Voronoi cells from the seeds that are the centers of the circles. Then for each Voronoi cell...

7 years ago | 0

Answered
How to randomly pick number from the vector and assign it to the element from the struct vector?
>> s=struct('whatever',cell(1,10)) s = 1×10 struct array with fields: whatever >> x=rand(1,...

7 years ago | 0

Answered
Delaunay Triangulation with a hole in the domain
Why reinvent the wheel? <https://fr.mathworks.com/matlabcentral/fileexchange/25555-mesh2d-delaunay-based-unstructured-mesh-gene...

7 years ago | 0

Answered
How to count the top five pairs (for each digit) which have the highest number of occurrences in a cell array?
C = {[1; 3; 5; 4; 6]; [1; 2; 3; 4; 5; 6; 7]; [1; 4; 3; 6]}; % generate list of all pairs from C elements u = unique(ca...

7 years ago | 1

| accepted

Answered
How to create a random permutation from two sets of numbers in one vector?
Separation in alternate groups c = [1 2 6 3 7 8 4 9 5 10]; from_a = c <= 5; % change accordingly, logical array, TRU...

7 years ago | 0

| accepted

Answered
How to generate correlated random sources drawn i.i.d from an arbitrary joint distribution in matlab?
m = 1000000; % size of the files % 2 groups % group1 3 files C12 = 0.2; C23 = 0.2; C13 = 0.2; G1 = [1 ...

7 years ago | 1

| accepted

Answered
How to find the roots of large number of polynomials arranged in matrix array
A vectorized code can be derived from this <https://math.stackexchange.com/questions/785/is-there-a-general-formula-for-solving-...

7 years ago | 0

Answered
How to generate a vector of two separate intervals without overlapping?
c = [a(randperm(length(a))) b(randperm(length(b)))]

7 years ago | 0

| accepted

Question


How TABLE retreive the variable names?
This example from the doc shows |table| is able to retrieve the variable names of the iput arguments list and uses them as colum...

7 years ago | 1 answer | 0

1

answer

Answered
Is it possible to vectorize this?
The orginal method is quite fast, for random intervals (they cover 50-60% of x) on my computer it takes 1.7 ms in average. Guill...

7 years ago | 0

Answered
Average based on logical mask and condition
Just put NaN on the 3km-grid at the place you want to discard Grid_3km_Masked = Grid_3km; Grid_3km_Masked(YourMask==0) ...

7 years ago | 0

| accepted

Answered
create cell array based on unique combinations in two columns
data=ceil(4*rand(20,3)) [m,n] = size(data); B = sortrows(data,[1 2]); G = mat2cell(B,diff([0; find(any(diff(B(:,[...

7 years ago | 1

| accepted

Answered
create cell array based on unique combinations in two columns
data=ceil(4*rand(20,3)) [~,~,J] = unique(data(:,[1,2]),'rows'); G = accumarray(J(:),(1:length(J)),[],@(r) {data(sort...

7 years ago | 1

Answered
Is it possible to vectorize this?
For generic x, A, no there is no direct way. What you might do is decomposing the set of intervals in bigger set of non-overl...

7 years ago | 0

Answered
Remove overlapping areas of 663 rectangles
<</matlabcentral/answers/uploaded_files/139889/unionrec.png>> data = xlsread('Rectangle points.xlsx'); data = reshap...

7 years ago | 1

| accepted

Answered
how do i discretize negative integers
_"This works for positive integers only."_ Wrong claim. It works for negative numbers, histc(-1.5,[-3 -2 -1]) ans =...

7 years ago | 2

Answered
Find the most common string out of all the strings
Edit: bug fix s1 = 'Romeo' s2 = 'Juliet' s3 = 'Rambo' s4 = 'Juliet' s5 = 'Romeo' s6 = 'Romeo' c = {s1...

7 years ago | 2

| accepted

Answered
How to construct a combinatorics array from two data sets with each combination having a specified number of elements?
Sad, people keep asking unreasonable thing. The number of combinations is 2^80, Each of those is 100 numbers so the size...

7 years ago | 1

Load more