Respondida
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...

más de 7 años hace | 0

| aceptada

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

más de 7 años hace | 3

| aceptada

Respondida
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...

más de 7 años hace | 0

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

más de 7 años hace | 1

| aceptada

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

más de 7 años hace | 1

| aceptada

Respondida
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...

más de 7 años hace | 0

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

más de 7 años hace | 0

Respondida
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...

más de 7 años hace | 2

| aceptada

Respondida
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...

más de 7 años hace | 2

| aceptada

Respondida
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...

más de 7 años hace | 0

Respondida
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),'.')

más de 7 años hace | 0

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

más de 7 años hace | 1

Respondida
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...

más de 7 años hace | 0

Respondida
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,...

más de 7 años hace | 0

Respondida
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...

más de 7 años hace | 0

Respondida
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...

más de 7 años hace | 1

| aceptada

Respondida
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...

más de 7 años hace | 0

| aceptada

Respondida
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 ...

más de 7 años hace | 1

| aceptada

Respondida
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-...

casi 8 años hace | 0

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

casi 8 años hace | 0

| aceptada

Pregunta


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

casi 8 años hace | 1 respuesta | 0

1

respuesta

Respondida
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...

casi 8 años hace | 0

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

casi 8 años hace | 0

| aceptada

Respondida
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(:,[...

casi 8 años hace | 1

| aceptada

Respondida
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...

casi 8 años hace | 1

Respondida
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...

casi 8 años hace | 0

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

casi 8 años hace | 1

| aceptada

Respondida
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 =...

casi 8 años hace | 2

Respondida
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...

casi 8 años hace | 2

| aceptada

Respondida
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...

casi 8 años hace | 1

Cargar más