Risposto
How to find the intersection of multiple arrays (or rows of a matrix) in a short code
Put in the cell then use comma list systax: c = {a, b, c, ...}; % or use mat2cell, num2cell depends how you store your 172 vect...

circa 4 anni fa | 1

| accettato

Risposto
2D Interpolation of data
You have scattered data, you should use scatteredInterpolant or similar, not interp2.

circa 4 anni fa | 0

| accettato

Risposto
Load an array instead of a struct with fields
Do this when loading, Container = load('Saving.mat'); Saving = Container.Saving; Check out doc of save ans struct so you won...

circa 4 anni fa | 1

| accettato

Risposto
scatteredInterpolant function is providing too much noise in interpolation
The problem raises from the fact that scatteredInterpolant use Delaunay triangulation, meaning that X and Y are assumed to have ...

circa 4 anni fa | 1

| accettato

Risposto
Without resorting to FEX/MEX, can the overhead of repeated calls to sparse() be avoided with operations on I, J, V directly?
EDIT: Here is the final code. Method used in B2 is the fatest; M = 10000; N = 10000; N_k = 100; A_k = cell(1,N_k); for k=1:...

circa 4 anni fa | 0

| accettato

Risposto
Does intlinprog use cuts during its Branch and Bound Algorithm?
The document CutMaxIterations: Number of passes through all cut generation methods before entering the branch-and-bound phase,...

circa 4 anni fa | 0

| accettato

Risposto
Vectorized way to assign columns/rows of matrix to struct array's field
split = num2cell(matrixToAssign,1); [structArray.field] = deal(split{;});

circa 4 anni fa | 0

Risposto
What is the best smoothing procedure to calculate differentials for a large number of data points (x,y)?
The Savitzky-Golay filter (moving polynomial fit) is a good filter that preserves decendly the slope. There is a similar thread...

circa 4 anni fa | 2

Risposto
Dot indexing is not supported for variables of this type??? Parfor loop, and global variable
The global variable is not accessible by the workers, and it will return EMPTY when you are trying tp access to it. Soo if you a...

circa 4 anni fa | 0

Risposto
sum of different columns to the desired value in Matlab
A=randi([4 30],10,1); lo = [1 1 1 1]; up = [10 10 5 5]; BCDE=lo+diff(round((cumsum([0, (up-lo)],2)).*(A-sum(lo))./sum(up-lo...

circa 4 anni fa | 1

| accettato

Risposto
sum of different columns to the desired value in Matlab
If you have the optimization toolbox A=randi([4 30],10,1); n = length(A); lo = [1 1 1 1]; up = [10 10 5 5]; m = length(up...

circa 4 anni fa | 1

Risposto
How to ask matlab to find mean only if there are less than 3 NaN values?
qq = [1 2 3 NaN; 1 NaN NaN NaN]; qqm = mean(qq','omitnan'); qqm(sum(isnan(qq),2)>=2) = NaN; qqm

circa 4 anni fa | 0

| accettato

Risposto
Backslash does not provided the solution with the smallest 2-norm
Few other methods to get least-norm solution A = rand(3,6) b = rand(3,1) % Methode 1, Christine, recommended x = lsqminnor...

circa 4 anni fa | 1

Risposto
Speeding up lsqlin to find the base of a matrix
Can you try this: A = mu-eye(size(A)); [Q,R,p] = qr(A,'vector'); n = [R(1:end-1,1:end-1)\R(1:end-1,end); -1]; n(p) = n/sum(n...

circa 4 anni fa | 1

| accettato

Risposto
Trying to parallel compute a function
"or maybe MATLAB automatically does this and my function is already running in parallel?" No. But if you vectorize your funct...

circa 4 anni fa | 0

Risposto
AUC or trapz for irregular shape that intersects itself
I use data you provided on other thread (the excel is horrible to read, if you could provide the data in mat file format it's be...

circa 4 anni fa | 0

| accettato

Risposto
Each PARFOR Worker Writes to the Same File
May be (I didn't test) you could write in binary file at a deterministic place: fileID = fopen('Results.bin','wb'); parfor ......

circa 4 anni fa | 0

| accettato

Risposto
How do i insert one value from one array to another array
See if s is what you want or not (not clear for me) A = [1,2;2,1;1,1;1,3;3,2] B = [0.5,0.5;2,2] k = dsearchn(B,A) AA = ...

circa 4 anni fa | 0

| accettato

Risposto
I need to repeat numbers in an array with a certain number of repetitions for each value without(repelem or repmat)
The old for-loop list_1 = [2;3;5;6]; list_2 = [1;4;3;1]; r = zeros(sum(list_2),1); start = 0; for k = 1:length(list_2) ...

circa 4 anni fa | 1

Risposto
I need to repeat numbers in an array with a certain number of repetitions for each value without(repelem or repmat)
Why prefer a simple method when one can do in a complicated manner: list_1 = [2;3;5;6] list_2 = [1;4;3;1] idx=cumsum(accuma...

circa 4 anni fa | 1

Risposto
How to generate a smooth derivative after fitting a curve to the data?
You have to FIT the spline, not interpolate. For example I use my own tool BSFK avalable in FEX. load Data.mat; pp = BSFK(x,y...

circa 4 anni fa | 0

| accettato

Risposto
how to bound voronoi polygons
Transform the voronoi cells to polyshape object, you can then make the intersection of the region you want to use to clip (the b...

circa 4 anni fa | 0

Risposto
How can I get permutations of a vector satisfying the given condition?
There are 9918 permutations according to this code B= [0 2 0 13 0 0; 1 3 0 14 0 13; 2 4 0 15 0 14; 3 5 0 16 0 15...

circa 4 anni fa | 1

| accettato

Risposto
How can I delete a row based on the value of the previous row?
If your data is sorted you could try this A = 1:0.1:10 A = uniquetol(A,2*(1-eps),'DataScale',1)

circa 4 anni fa | 0

Risposto
How can I delete a row based on the value of the previous row?
This avoids deletetion which like growsing array wouls kill the performance. A=[10, 11.5, 13.3 13.5 13.7 17]; keep = false(s...

circa 4 anni fa | 1

Risposto
2D sliding/moving/running average window
Just some hint if your want to implement efficiently using loop : To do mean, you might do sliding sum onf the data, then divid...

circa 4 anni fa | 0

| accettato

Risposto
question about command 'mat2cell'
I = rand(128,256); n = 16; mat2cell(I, n*ones(1,size(I,1)/n), n*ones(1,size(I,2)/n))

circa 4 anni fa | 0

| accettato

Risposto
How can I create a Delanay point in a cube?
A cube can be devided in 6 tetrahedra nx=4; ny=3; nz=2; grid = arrayfun(@(n)linspace(0,n,n+1),[nx,ny,nz], 'unif', 0); [gr...

circa 4 anni fa | 0

| accettato

Risposto
How do I put my values in certain bins and retrieve the values from the highest count bin
Adapt this to your need % Example data A=rand(2,3,20); A(randi(numel(A),1,10))=0; [m,n,p] = size(A); edges = 0:0.1:1; A(...

circa 4 anni fa | 1

| accettato

Risposto
How to generate all possible permutations of an array having numbers from 1 to 24?
perms(1:4) % toy example perms(1:24) % what you ask is Why? Because you need (factorial(24)*24*8)/(1024^4) =~ 10^14 Tera b...

circa 4 anni fa | 1

Carica altro