Community Profile

Bruno Luong

Last seen: Today
1,061 total contributions since 2009

View details...

Contributions in
View by

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

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

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

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

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

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

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

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

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

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

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

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

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

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

How can ı solve this constraint optimization problem?
Hint: you should find x=y=1

1 day ago | 1

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

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

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

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

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

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

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

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

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

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

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