Answered

Bug with conv2

The answer is correct. May be you expect the result with sliding sum with unflip kernel which is of course wrong.

Bug with conv2

The answer is correct. May be you expect the result with sliding sum with unflip kernel which is of course wrong.

17 days ago | 1

Answered

How to replace for loop with vectorization?

[iii,jj]=ndgrid(ii,1:size(res,2)); v=accumarray([iii(:) jj(:)], res(:))

How to replace for loop with vectorization?

[iii,jj]=ndgrid(ii,1:size(res,2)); v=accumarray([iii(:) jj(:)], res(:))

24 days ago | 1

Answered

Generate a random matrix without repeating any value in row and column.

A=mod((0:3)+(0:3)',4)+1; R=A(randperm(end),randperm(end))

Generate a random matrix without repeating any value in row and column.

A=mod((0:3)+(0:3)',4)+1; R=A(randperm(end),randperm(end))

26 days ago | 0

| accepted

Answered

Getting back the solution to Ax=b after reordering A

This is correct: clc clear close all A=[4 1 2 0.5 2;1 0.5 0 0 0;2 0 3 0 0;0.5 0 0 5/8 0;2 0 0 0 16]; % P_amd=amd(A); P_amd...

Getting back the solution to Ax=b after reordering A

This is correct: clc clear close all A=[4 1 2 0.5 2;1 0.5 0 0 0;2 0 3 0 0;0.5 0 0 5/8 0;2 0 0 0 16]; % P_amd=amd(A); P_amd...

27 days ago | 0

Answered

how can i generate the random numbers for specific probabilites

v = [ 0, 15, 25, 35, 45, 20]; % values P = [0.01, 0.15, 0.20, 0.50, 0.12, 0.02]; % the correspond probability c ...

how can i generate the random numbers for specific probabilites

v = [ 0, 15, 25, 35, 45, 20]; % values P = [0.01, 0.15, 0.20, 0.50, 0.12, 0.02]; % the correspond probability c ...

27 days ago | 0

| accepted

Answered

combination and their sum

A = [4 2; 5 7; 3 1] m = size(A,1); b = dec2bin(0:2^m-1,m)-'0'; C = A((1:m)+m*b).' Result (each column is a co...

combination and their sum

A = [4 2; 5 7; 3 1] m = size(A,1); b = dec2bin(0:2^m-1,m)-'0'; C = A((1:m)+m*b).' Result (each column is a co...

28 days ago | 0

Answered

How to calculate determinant of matrices without loop?

a(:,1).*b(:,2)-a(:,2).*b(:,1)-a(:,1).*b(:,3)+a(:,3).*b(:,1)+a(:,2).*b(:,3)-a(:,3).*b(:,2)

How to calculate determinant of matrices without loop?

a(:,1).*b(:,2)-a(:,2).*b(:,1)-a(:,1).*b(:,3)+a(:,3).*b(:,1)+a(:,2).*b(:,3)-a(:,3).*b(:,2)

1 month ago | 1

| accepted

Answered

Equality constraint in quadratic programming

Yes, il looks right to me. EDIT: No Q(3,1) must be 0 Q=[2 1 0; 1 4 0 ; 0 0 6]

Equality constraint in quadratic programming

Yes, il looks right to me. EDIT: No Q(3,1) must be 0 Q=[2 1 0; 1 4 0 ; 0 0 6]

1 month ago | 0

| accepted

Answered

Find matching points from two coordinate systems

Look for the literature of image registration. For simple rotation/scaling/translation you can use Matt J's submission For mo...

Find matching points from two coordinate systems

Look for the literature of image registration. For simple rotation/scaling/translation you can use Matt J's submission For mo...

1 month ago | 0

Answered

How vectorize this operation

n=10 m=3 x=rand(n,1) y=rand(m,1) % your method z = nan(length(x),1);% Just some fake data to define the size of z. could ...

How vectorize this operation

n=10 m=3 x=rand(n,1) y=rand(m,1) % your method z = nan(length(x),1);% Just some fake data to define the size of z. could ...

1 month ago | 1

| accepted

Answered

Solve Overdetermined Linear System

For overdetermined system the "\" returns least-square solution, meaning it doesn't solve exactly your system, but returnes the ...

Solve Overdetermined Linear System

For overdetermined system the "\" returns least-square solution, meaning it doesn't solve exactly your system, but returnes the ...

1 month ago | 0

Answered

How to remove duplicates in matrix with condition

X = [1 10;2 20;3 30;3 31;3 32]; Xs=sortrows(X); [~,I]=unique(Xs(:,1),'last'); XResult = Xs(I,:)

How to remove duplicates in matrix with condition

X = [1 10;2 20;3 30;3 31;3 32]; Xs=sortrows(X); [~,I]=unique(Xs(:,1),'last'); XResult = Xs(I,:)

1 month ago | 1

| accepted

Answered

How to taker power of a permutaion matrix

You have 2 ways to compute it, from the permutation itself, or using the permutation matrix then raise a power of it. % Generat...

How to taker power of a permutaion matrix

You have 2 ways to compute it, from the permutation itself, or using the permutation matrix then raise a power of it. % Generat...

1 month ago | 0

| accepted

Answered

How to design a Toeplitz matrix with negative lower triangle elements and zero main diagonal elements

toeplitz(0:-1:-5,0:5)

How to design a Toeplitz matrix with negative lower triangle elements and zero main diagonal elements

toeplitz(0:-1:-5,0:5)

2 months ago | 1

| accepted

Answered

How to define a covariance matrix that is positive semi definite?

L=randn(3); sigma=L'*L

How to define a covariance matrix that is positive semi definite?

L=randn(3); sigma=L'*L

2 months ago | 0

Question

path of a mfile not on search path

When an mfile is not on the search path or current path and when user types the name, MATLAB find it and issues a suggestion >>...

2 months ago | 2 answers | 0

Answered

How to generate a random data vector that follows a constraint

This will generate uniform distribution (within to polytope) N = 10; Etotal = 0; E = -log(rand(N+1,1)); E = E(1:N,:)./sum(...

How to generate a random data vector that follows a constraint

This will generate uniform distribution (within to polytope) N = 10; Etotal = 0; E = -log(rand(N+1,1)); E = E(1:N,:)./sum(...

2 months ago | 2

| accepted

Answered

Increasing Java Heap Memory of target machine so that EXE runs on target machine with MCR

According to my test, the stand alone app uses the sames amount of java heap memory than your MATLAB preferences. To set the a...

Increasing Java Heap Memory of target machine so that EXE runs on target machine with MCR

According to my test, the stand alone app uses the sames amount of java heap memory than your MATLAB preferences. To set the a...

2 months ago | 0

| accepted

Answered

Model of a crowd on concert venue or how to distribute random points according to the 2D window distribution

Torsten's rejection might bias the distribution. One of the better approach is to repell the points when they are close to each...

Model of a crowd on concert venue or how to distribute random points according to the 2D window distribution

Torsten's rejection might bias the distribution. One of the better approach is to repell the points when they are close to each...

2 months ago | 0

Answered

How to genetate random number under constraint

Similar question has been answered in this thread

How to genetate random number under constraint

Similar question has been answered in this thread

2 months ago | 0

Answered

How can I evenly distribute Points inside of a triangle?

Use mesh generator like MESH2D

How can I evenly distribute Points inside of a triangle?

Use mesh generator like MESH2D

2 months ago | 1

| accepted

Answered

What code to make figure window fullscreen with subplot?

Check out This thread hope it's not obsolete. If you run on Windows WindowAPI (Jan's reply) is the only one which makes real ful...

What code to make figure window fullscreen with subplot?

Check out This thread hope it's not obsolete. If you run on Windows WindowAPI (Jan's reply) is the only one which makes real ful...

2 months ago | 0

Answered

could anyone help me to calculate the euclidean distance for the matrix.

Hi Christtine, very good initiative. I think at least 90% of use-case would be p=2.

could anyone help me to calculate the euclidean distance for the matrix.

Hi Christtine, very good initiative. I think at least 90% of use-case would be p=2.

2 months ago | 0

Answered

What is the different between "null" command and "svd" command

Beside the trivial must do "reading the doc" you can just type edit null to see how NULL call SVD and keeps the singular vecto...

What is the different between "null" command and "svd" command

Beside the trivial must do "reading the doc" you can just type edit null to see how NULL call SVD and keeps the singular vecto...

2 months ago | 0

Answered

Is this for-loop vectorizable?

I don't think sequential search can be vectorizable. You might improve a bit of the search by implementing dichotomy seach rath...

Is this for-loop vectorizable?

I don't think sequential search can be vectorizable. You might improve a bit of the search by implementing dichotomy seach rath...

2 months ago | 0

Answered

How to draw random number from a conditional distribution

Your problem is not well defined, there are many Y that can meet such requirement (if you guys think it is impossible beside a s...

How to draw random number from a conditional distribution

Your problem is not well defined, there are many Y that can meet such requirement (if you guys think it is impossible beside a s...

2 months ago | 0

Answered

How do i write a code which can calculate the cross production of two vectors?

If A and B are 5 x 1 null([a;b]) returns a (5 x 3), 3 vectors in R^5 basis of NULL(SPAN(a,b))

How do i write a code which can calculate the cross production of two vectors?

If A and B are 5 x 1 null([a;b]) returns a (5 x 3), 3 vectors in R^5 basis of NULL(SPAN(a,b))

2 months ago | 0

Answered

Does inpolygon work for latitudes and longitudes on the surface of the earth?

A polygon in lat/lon will NOT map to a "polygon" on the sphere. A "polygon" on the sphere composed by edges that are grand circl...

Does inpolygon work for latitudes and longitudes on the surface of the earth?

A polygon in lat/lon will NOT map to a "polygon" on the sphere. A "polygon" on the sphere composed by edges that are grand circl...

2 months ago | 0

Answered

Format number in the same format as disp

>> x=logspace(1,3,10) x = 1.0e+03 * 0.0100 0.0167 0.0278 0.0464 0.0774 0.1292 0.2154 0.3594...

Format number in the same format as disp

>> x=logspace(1,3,10) x = 1.0e+03 * 0.0100 0.0167 0.0278 0.0464 0.0774 0.1292 0.2154 0.3594...

2 months ago | 1

Answered

submitWithConfiguration not working in matlab R2019b

The problem is in the statement parts = parts(conf); In MATLAB 2019B, you cannot use the same name of variable and function, b...

submitWithConfiguration not working in matlab R2019b

The problem is in the statement parts = parts(conf); In MATLAB 2019B, you cannot use the same name of variable and function, b...

2 months ago | 0

| accepted