Answered

Is there any MATLAB toolbox that can find the local MAX of a piece-wise multi-variable function?

fmincon and friends if you have the toolbox.

Is there any MATLAB toolbox that can find the local MAX of a piece-wise multi-variable function?

fmincon and friends if you have the toolbox.

12 hours ago | 0

Answered

How to perform logical AND on intervals of contiguous locations

x = logical([0, 1, 0,0, 1,1, 0,0,0, 1,1,1, 0]) y = logical([0, 1, 1,0, 1,1, 0,1,0, 1,0,1, 0]) code without loop or groupping, ...

How to perform logical AND on intervals of contiguous locations

x = logical([0, 1, 0,0, 1,1, 0,0,0, 1,1,1, 0]) y = logical([0, 1, 1,0, 1,1, 0,1,0, 1,0,1, 0]) code without loop or groupping, ...

1 day ago | 0

| accepted

Answered

Create 9x9 matrix with RANDI between [0,2] with each 0,1, and 2 repeating three times each per column.

[~,A] = sort(rand(9)); A = mod(A,3)

Create 9x9 matrix with RANDI between [0,2] with each 0,1, and 2 repeating three times each per column.

[~,A] = sort(rand(9)); A = mod(A,3)

2 days ago | 1

Answered

performing a least squares with regularisation in matlab

Simpless method: n = size(X,2); % 8 lambda = 1e-6; % <= regularization parameter, 0 no regularization, larger value stronger r...

performing a least squares with regularisation in matlab

Simpless method: n = size(X,2); % 8 lambda = 1e-6; % <= regularization parameter, 0 no regularization, larger value stronger r...

2 days ago | 0

Answered

Generate random sequence number with condition

P=interp1([0 0.9 1],[0.1 2 3.5],'pchip','pp'); n = 1e6; % 200 in your case % here is the array of random r=ppval(P,rand(1,n))...

Generate random sequence number with condition

P=interp1([0 0.9 1],[0.1 2 3.5],'pchip','pp'); n = 1e6; % 200 in your case % here is the array of random r=ppval(P,rand(1,n))...

2 days ago | 0

| accepted

Answered

Is there a faster way to run my code?

Use knnsearch if you have the right toolbox (I don't so the code is untested) [index_hard, dist_hard] = knnsearch(C,r,'K',1,'Di...

Is there a faster way to run my code?

Use knnsearch if you have the right toolbox (I don't so the code is untested) [index_hard, dist_hard] = knnsearch(C,r,'K',1,'Di...

2 days ago | 0

Answered

Can someone provide me the theory and math behind this function of eigen?

for each column number j, A*V = B*V*D implies A*xj = lambdaj*B*xj where xj = V(:,j) lambdaj = D(j,j) This is just a gene...

Can someone provide me the theory and math behind this function of eigen?

for each column number j, A*V = B*V*D implies A*xj = lambdaj*B*xj where xj = V(:,j) lambdaj = D(j,j) This is just a gene...

3 days ago | 0

Answered

Is there any method to accelerate many small matrix and vector's "mldivide" (4*4)?

Use my FEX file of MultiSolver num = 4000000; A = rand(4,4,num); b = rand(4,num); x = zeros(4,num); tic for i=1:num ...

Is there any method to accelerate many small matrix and vector's "mldivide" (4*4)?

Use my FEX file of MultiSolver num = 4000000; A = rand(4,4,num); b = rand(4,num); x = zeros(4,num); tic for i=1:num ...

3 days ago | 0

Answered

How do I swap the elements in the major diagonal with those in the minor diagonal?

x=[1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2] s=size(x); m=min(s); n=s(2); i=1:m; id=sub2ind(s,i,i); iad=sub2ind(s,i,n+...

How do I swap the elements in the major diagonal with those in the minor diagonal?

x=[1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2] s=size(x); m=min(s); n=s(2); i=1:m; id=sub2ind(s,i,i); iad=sub2ind(s,i,n+...

3 days ago | 1

Answered

Efficiently calculating sum-thresholds across vector

This works regardless the sign of sample % Test data samples = 5*rand(1,10000); samples = samples+0.5*randn(size(samples)); %...

Efficiently calculating sum-thresholds across vector

This works regardless the sign of sample % Test data samples = 5*rand(1,10000); samples = samples+0.5*randn(size(samples)); %...

3 days ago | 0

Answered

Find min and max of consecutive values in an array and save these values in a nx2 matrix

v = [670; 671; 672; 680; 681; 682; 700; 701; 702; 703] idx = find([true; diff(v(:))~=1; true]); minmaxseq = [v(idx(1:end-1))...

Find min and max of consecutive values in an array and save these values in a nx2 matrix

v = [670; 671; 672; 680; 681; 682; 700; 701; 702; 703] idx = find([true; diff(v(:))~=1; true]); minmaxseq = [v(idx(1:end-1))...

3 days ago | 2

| accepted

Answered

Isolate first non-zero integer of each element of an array

A = [0.00663270674527115 36798861787.4757 0.0165559157141383 0.00845305563147772 0.000298646998074807 2561194549424.91]...

Isolate first non-zero integer of each element of an array

A = [0.00663270674527115 36798861787.4757 0.0165559157141383 0.00845305563147772 0.000298646998074807 2561194549424.91]...

3 days ago | 1

| accepted

Answered

abcd is efghijk?

function C= circulant(x) n=length(x); C=zeros(n,n); C(:,1)=x; for j=2:n C(:,j)=[C(n,j-1); C(1:n-1,j-1)]; end

abcd is efghijk?

function C= circulant(x) n=length(x); C=zeros(n,n); C(:,1)=x; for j=2:n C(:,j)=[C(n,j-1); C(1:n-1,j-1)]; end

6 days ago | 0

| accepted

Answered

abcd is efghijk?

function C= circulant(x) n = length(x); C = x(mod((1:n)'-(1:n),n)+1);

abcd is efghijk?

function C= circulant(x) n = length(x); C = x(mod((1:n)'-(1:n),n)+1);

6 days ago | 0

Question

Memory leak with OPENGL hardware

Context: I have a matlab code that output a complex 3D graphic animation on GUI figure, involving patch, lines, markers, camera ...

6 days ago | 0 answers | 0

Answered

Obtain all integer partitions for a given integer

I wrote a short function that doesn't need to post-proceesed with UNIQUE (wast of time and memory) when using with NSUMK or allv...

Obtain all integer partitions for a given integer

I wrote a short function that doesn't need to post-proceesed with UNIQUE (wast of time and memory) when using with NSUMK or allv...

7 days ago | 0

Answered

abcd is efghijk?

function C= circulant(x) toeplitz(x,circshift(flip(x),1)) end

abcd is efghijk?

function C= circulant(x) toeplitz(x,circshift(flip(x),1)) end

7 days ago | 0

Answered

Set of sequnce number

>> A = [1,2,3,4,5,6,7,8] A = 1 2 3 4 5 6 7 8 >> polyval(A,10) ans = 12345678...

Set of sequnce number

>> A = [1,2,3,4,5,6,7,8] A = 1 2 3 4 5 6 7 8 >> polyval(A,10) ans = 12345678...

8 days ago | 0

Answered

Histcounts including values beyond bin edges

Append -Inf/+Inf in your finite edges

Histcounts including values beyond bin edges

Append -Inf/+Inf in your finite edges

8 days ago | 1

| accepted

Answered

Meaning of less/greater than in handle objects

I believe the graphic handle object at one point of MATLAB history (before R2014b?) is just a double numbers unique assigned too...

Meaning of less/greater than in handle objects

I believe the graphic handle object at one point of MATLAB history (before R2014b?) is just a double numbers unique assigned too...

8 days ago | 0

| accepted

Answered

How can I access the last values of a list using end?

list(end-3)

How can I access the last values of a list using end?

list(end-3)

10 days ago | 1

| accepted

Answered

Matrix having one row

Avoid using LENGTH Replace with for i = 1:size(x,1) ... end

Matrix having one row

Avoid using LENGTH Replace with for i = 1:size(x,1) ... end

11 days ago | 0

| accepted

Answered

Memory cost of multiplying sparse matrices

I guess MATLAB creates a temporary buffer of length equals to the number of rows of A when A*B is invoked. The exact detail only...

Memory cost of multiplying sparse matrices

I guess MATLAB creates a temporary buffer of length equals to the number of rows of A when A*B is invoked. The exact detail only...

11 days ago | 0

Answered

How can I pseudorandomize with constrains and make spesific number spread equally among the array?

Unzip this attached file, you'll get a pfile r1234.p Call it A = r1234 You'll get the result as specified.

How can I pseudorandomize with constrains and make spesific number spread equally among the array?

Unzip this attached file, you'll get a pfile r1234.p Call it A = r1234 You'll get the result as specified.

11 days ago | 0

| accepted

Answered

Replacing several values in multidimensional array simultaneously

A(:,:,1) = [1 2 3 ; 4 5 6]; A(:,:,2) = [7 8 9 ; 10 11 12]; s = size(A); A(:, sub2ind(s(2:3),[2 3],[1 2])) = 0 % = [0 0; 0...

Replacing several values in multidimensional array simultaneously

A(:,:,1) = [1 2 3 ; 4 5 6]; A(:,:,2) = [7 8 9 ; 10 11 12]; s = size(A); A(:, sub2ind(s(2:3),[2 3],[1 2])) = 0 % = [0 0; 0...

12 days ago | 0

| accepted

Answered

How to generate a matrix with assigned probability?

it doesn't matter whereas it run in for-loop or not. x = 0.8; % probability of 1s m = 5; n = 2; % for ... A = rand(m,n)...

How to generate a matrix with assigned probability?

it doesn't matter whereas it run in for-loop or not. x = 0.8; % probability of 1s m = 5; n = 2; % for ... A = rand(m,n)...

12 days ago | 1

| accepted

Answered

Permutations of array retaining sub-array groups together

Try this: A = [ 1 2 3 4 5 6 7 8] G = [ 1 2 2 2 3 4 5 5 ] l = diff(find([true,diff(G)>0,true])); Ag = mat2cell(A, 1, l); A...

Permutations of array retaining sub-array groups together

Try this: A = [ 1 2 3 4 5 6 7 8] G = [ 1 2 2 2 3 4 5 5 ] l = diff(find([true,diff(G)>0,true])); Ag = mat2cell(A, 1, l); A...

13 days ago | 1

| accepted