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

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

6 years ago | 0

| accepted

Submitted


All Permutations of integers with sum criteria
All Pernutations of integers with sum criteria

6 years ago | 2 downloads |

5.0 / 5

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

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

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

6 years 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)

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

6 years 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,...

6 years 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

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

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

6 years 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

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

6 years ago | 0

Answered
Inserting a row in a matrix in a precise place
[~,r] = histc(b, [A(:,1); Inf]); Ab = [A(1:r,:); b; A(r+1:end,:)]; % r+1 is the row-position of b in the new array

6 years ago | 0

Answered
Row vector divide by row vector
It returns the scalar C (maxtrix 1x1) such that C*B ~ A in the sense that norm(C*B - A)^2 % or equivalently sum((C*B - A)...

6 years ago | 0

| accepted

Answered
Minimizing norm( a_i x - ( y B_i + c_i ) ) with constraint
If you have optimization toolbox you can do (see my other answer for definition of A, b and z) z= fmincon(@(z) norm(A*z-b,2).^2...

6 years ago | 0

Answered
Minimizing norm( a_i x - ( y B_i + c_i ) ) with constraint
So you want more or less Minimize | A*z - b |^2 with the constraint | z | <= 1. where |.| designates the l2 norm. I believe ...

6 years ago | 2

Question


The Mathworks Support Team
I have seen The Mathworks Support Team creates various questions and answers that provide a lot of interesting knowledges, trick...

6 years ago | 1 answer | 0

1

answer

Answered
Obtain 2D Histogram from 3D matrix and 2D pdf
Check this out

6 years ago | 0

Answered
Find all the possibles paths between 2 nodes in undirected graph
Test script % Generate random undirect graph % https://www.mathworks.com/matlabcentral/answers/563732 n = 10; % number of nod...

6 years ago | 0

| accepted

Answered
Properties of adjacency matrix
Another way - most direct perhaps link to matrix property - is using this property of Laplacian matrix: "The number of connecte...

6 years ago | 0

Answered
How to add repeated elements to a vector without looping?
accumarray([1 2 4 3 2 1 1]', 1)' Put [1 1 1 1 1 1 1]' as second argument if the values to accumulate are not uniform. (importa...

6 years ago | 0

| accepted

Answered
How to write pentadigonal matix?
m = 4; n = 3*m; T = diag(ones(1,n-3),3); A = T + T'; B = ones(3)-5*eye(3); A = A + kron(eye(m),B)

6 years ago | 0

Answered
Properties of adjacency matrix
Here is a quick and dirty calculation of connexed component using adjacent matrix. It returns the same output as MATLAB conncomp...

6 years ago | 0

| accepted

Answered
Generating parings of numbers and the pairs must not contain the same numbers
Use derangement (randpermfull function used below) n= 20; D = [1:n; randpermfull(n)]' R = D(randperm(n),:)

6 years ago | 0

| accepted

Answered
Generating parings of numbers and the pairs must not contain the same numbers
Not sure if you require each column is the set 1:20 if yes see my other answer. If not upperbnd = 20; % values in [1:upperbnd]...

6 years ago | 0

Answered
Finding unique rows using "uniquetol" from top
I suppose you can do something like this. I'm affraid the way UNIQUETOL and ISMEMBERTOL consider the TOL internally, and in some...

6 years ago | 0

| accepted

Answered
Discretizing the probability distribution
To generate 1D random variable with a prescribed continuous PDF, one need 2 things: able to integrate pdf (called cdf) able to...

6 years ago | 0

| accepted

Load more