Answered

How to split a 3d matrix into sub-3d matrices?

probably you can use mat2cell IMO splitting a matrix in cell is rarely a good idea if you want your code works decenly in spee...

How to split a 3d matrix into sub-3d matrices?

probably you can use mat2cell IMO splitting a matrix in cell is rarely a good idea if you want your code works decenly in spee...

1 hour ago | 0

Answered

Where has depfun gone? or How to make a dependency graph?

https://www.mathworks.com/help/matlab/matlab_prog/identify-dependencies.html https://www.mathworks.com/help/matlab/ref/matlab.c...

Where has depfun gone? or How to make a dependency graph?

https://www.mathworks.com/help/matlab/matlab_prog/identify-dependencies.html https://www.mathworks.com/help/matlab/ref/matlab.c...

2 hours ago | 0

Answered

random matrix with a given number of specified elements

User inputs matsz = [3,3]; n1 = 4; % number of desired 1s, no need to specify for 0s Generate B = zeros(matsz); % + 0; B(r...

random matrix with a given number of specified elements

User inputs matsz = [3,3]; n1 = 4; % number of desired 1s, no need to specify for 0s Generate B = zeros(matsz); % + 0; B(r...

3 hours ago | 1

Answered

how to display how many looping are working on

for x=1:TTI fprintf('iteration %d/%d\n', x, TTI); % do stuff % .... end

how to display how many looping are working on

for x=1:TTI fprintf('iteration %d/%d\n', x, TTI); % do stuff % .... end

11 hours ago | 0

Answered

How to find a row of a large matrix

It seems you run old MATLAB version without auto-expansion capability. This will work for any version: row = find(ismember(X,[...

How to find a row of a large matrix

It seems you run old MATLAB version without auto-expansion capability. This will work for any version: row = find(ismember(X,[...

11 hours ago | 0

| accepted

Answered

How can one extract this vector from a matrix?

Avg = mean(reshape(M(:,2:3)',12*2,[])); [(1:length(Avg)); Avg]'

How can one extract this vector from a matrix?

Avg = mean(reshape(M(:,2:3)',12*2,[])); [(1:length(Avg)); Avg]'

13 hours ago | 0

Answered

array indexing with another array in multidimensional matrices

A=randi(10,5,4,3,2) idx=[1,1;2,1;3,1;1,2;2,2;3,2] Then sz=size(A); Aidx = A(:,:,sub2ind(sz(3:4),idx(:,1),idx(:,2)))

array indexing with another array in multidimensional matrices

A=randi(10,5,4,3,2) idx=[1,1;2,1;3,1;1,2;2,2;3,2] Then sz=size(A); Aidx = A(:,:,sub2ind(sz(3:4),idx(:,1),idx(:,2)))

19 hours ago | 0

Answered

all possible combinations of vectors of unknown quantity and length

Generate vectors of consecutive integers to be combined A = [2 5 8 9]; c = arrayfun(@(n) 1:n, A, 'unif', 0) Generate combinat...

all possible combinations of vectors of unknown quantity and length

Generate vectors of consecutive integers to be combined A = [2 5 8 9]; c = arrayfun(@(n) 1:n, A, 'unif', 0) Generate combinat...

21 hours ago | 0

| accepted

Answered

How do I obtain the derivatives after interp2 with the 'spline' option?

Checkout this File exchange I haven't visited this file for long time. At the time I wrote the interface is not very intuitive,...

How do I obtain the derivatives after interp2 with the 'spline' option?

Checkout this File exchange I haven't visited this file for long time. At the time I wrote the interface is not very intuitive,...

22 hours ago | 0

Answered

How can one make this program work? (fmin question)

x=zeros(10,1); for a=1:1:10 x(a,1)=fminbnd(@(x) fun(x,a), 0, 2) % minimizes fun(x,a) end

How can one make this program work? (fmin question)

x=zeros(10,1); for a=1:1:10 x(a,1)=fminbnd(@(x) fun(x,a), 0, 2) % minimizes fun(x,a) end

23 hours ago | 1

| accepted

Answered

How to reshape matrix 2 columns by 2 columns

You want a reshape? Here is reshape method: B = reshape(permute(reshape(A,size(A,1),2,[]),[1 3 2]),[],2)

How to reshape matrix 2 columns by 2 columns

You want a reshape? Here is reshape method: B = reshape(permute(reshape(A,size(A,1),2,[]),[1 3 2]),[],2)

23 hours ago | 0

Answered

Which is more efficient when applied to a sparse matrix, find or logical indexing ?

For sparse matrix using FIND to get non-zero elements is the best - bar none. It's design for it and the data are internally ran...

Which is more efficient when applied to a sparse matrix, find or logical indexing ?

For sparse matrix using FIND to get non-zero elements is the best - bar none. It's design for it and the data are internally ran...

1 day ago | 1

Answered

Particularly strange bug using the eval function

This is NOT a bug but documenented behavior from recent release Read from R2019b release note "If you intend to use x as a va...

Particularly strange bug using the eval function

This is NOT a bug but documenented behavior from recent release Read from R2019b release note "If you intend to use x as a va...

1 day ago | 1

Answered

How do I get every combination of 3 vectors?

yourvector1 = ... yourvector2 = ... yourvector3 = ... Then c = {yourvector1, yourvector2, yourvector3}; c = flip(c); [c{:}...

How do I get every combination of 3 vectors?

yourvector1 = ... yourvector2 = ... yourvector3 = ... Then c = {yourvector1, yourvector2, yourvector3}; c = flip(c); [c{:}...

1 day ago | 0

| accepted

Answered

How can ı solve this constraint optimization problem?

Hint: you should find x=y=1

How can ı solve this constraint optimization problem?

Hint: you should find x=y=1

1 day ago | 1

Answered

Write a function max_sum that takes v a row vector of numbers & n,a positive integer as inputs.The function needs to find n consecutive elements of v whose sum is largest possible.It returns summa & index of first element of n consecutive integers.

function [s,index] = maxmovsum(v, N) c = movsum(v,N); [s,index] = max(c(1+floor(N/2):end-floor((N-1)/2))); end

Write a function max_sum that takes v a row vector of numbers & n,a positive integer as inputs.The function needs to find n consecutive elements of v whose sum is largest possible.It returns summa & index of first element of n consecutive integers.

function [s,index] = maxmovsum(v, N) c = movsum(v,N); [s,index] = max(c(1+floor(N/2):end-floor((N-1)/2))); end

2 days ago | 0

Answered

Get Interpolation transfer relation matrix instead of interpolated values

The matrix can be derived from linear interpolation method only, by linear I meant the output is linear to the input. SPLINE met...

Get Interpolation transfer relation matrix instead of interpolated values

The matrix can be derived from linear interpolation method only, by linear I meant the output is linear to the input. SPLINE met...

2 days ago | 2

| accepted

Answered

Nested for loops without repetition

I won't fix your code with 4/5 nested for-loops and if conditions and .... I give you an alternative code. It requires a functi...

Nested for loops without repetition

I won't fix your code with 4/5 nested for-loops and if conditions and .... I give you an alternative code. It requires a functi...

2 days ago | 0

| accepted

Submitted

All Permutations of integers with sum criteria

All Pernutations of integers with sum criteria

2 days ago | 8 downloads |

Answered

Is there any method to calculate the inverse of matrix which changed a few values?

Apply this Sherman Morisson's formula in the page provided by Vladimir, if one set a single change: A(i,j) to new value newAij, ...

Is there any method to calculate the inverse of matrix which changed a few values?

Apply this Sherman Morisson's formula in the page provided by Vladimir, if one set a single change: A(i,j) to new value newAij, ...

2 days ago | 0

Answered

How can I determine the amount of times a certain value can be achieved by summing values in a matrix?

I put here the code with limiting CPU time so one can run up to 50 samples. Matt should get credit for his original idea. fulll...

How can I determine the amount of times a certain value can be achieved by summing values in a matrix?

I put here the code with limiting CPU time so one can run up to 50 samples. Matt should get credit for his original idea. fulll...

3 days ago | 0

Answered

How to limit calculation precision?

Perhaps all you need is cast all your input data/parameters/constants related your program to SINGLE. The relative precision is...

How to limit calculation precision?

Perhaps all you need is cast all your input data/parameters/constants related your program to SINGLE. The relative precision is...

3 days ago | 1

Answered

Complex nested loops- matrix indexing

A=randi(10,20,20) % some tes matrix, replace it with yours B = A(6:1:17, 3:-1:2)

Complex nested loops- matrix indexing

A=randi(10,20,20) % some tes matrix, replace it with yours B = A(6:1:17, 3:-1:2)

3 days ago | 0

Answered

K-th order neighbors in graph

Given A an (n x n) symmetric ajadcent matrix (undirected graph), and k the order (integer scalar), I propose this algorithm to f...

K-th order neighbors in graph

Given A an (n x n) symmetric ajadcent matrix (undirected graph), and k the order (integer scalar), I propose this algorithm to f...

3 days ago | 0

Answered

Problem of ``sprandn'': the number of nonzero elements is inconsistent with density

The approximation is only good when density << 1. I think SPRAND/SPRANDN simply create random draw of (density*m*n) pairs of (i,...

Problem of ``sprandn'': the number of nonzero elements is inconsistent with density

The approximation is only good when density << 1. I think SPRAND/SPRANDN simply create random draw of (density*m*n) pairs of (i,...

3 days ago | 2

| accepted

Answered

Is there a way to do the following without running a for loop.

y = randi(5,1,5)' Then A = accumarray([(1:5)' y(:)], 1, [5 5]); or A = zeros(5,5); A(sub2ind(size(A),1:5,y'))=1

Is there a way to do the following without running a for loop.

y = randi(5,1,5)' Then A = accumarray([(1:5)' y(:)], 1, [5 5]); or A = zeros(5,5); A(sub2ind(size(A),1:5,y'))=1

3 days ago | 0

| accepted

Answered

Raw by column wise multiplication of matrices

>> A=randi(10,4,3) A = 6 5 4 3 4 1 8 4 10 2 8 10 >> B=randi(10,3,4...

Raw by column wise multiplication of matrices

>> A=randi(10,4,3) A = 6 5 4 3 4 1 8 4 10 2 8 10 >> B=randi(10,3,4...

4 days ago | 1

| accepted

Answered

Smooth derivative of a matrix

Here is my take on the derivative by using a phase correction on all components of Uk. As example, I use the random matrix H g...

Smooth derivative of a matrix

Here is my take on the derivative by using a phase correction on all components of Uk. As example, I use the random matrix H g...

4 days ago | 0

Answered

Sorting a matrix using it's index

[Asort,idA] = sort(A,2) m = size(A,1); ilinA = (idA-1)*m+(1:m)'; Asort3 = A(ilinA) % get back Asort

Sorting a matrix using it's index

[Asort,idA] = sort(A,2) m = size(A,1); ilinA = (idA-1)*m+(1:m)'; Asort3 = A(ilinA) % get back Asort

4 days ago | 0

Answered

Smooth derivative of a matrix

I give just an idea that is like a big hammer. What if you use minimization technique to get a closest eigen vectors to the prev...

Smooth derivative of a matrix

I give just an idea that is like a big hammer. What if you use minimization technique to get a closest eigen vectors to the prev...

4 days ago | 0