Answered

How to do forward, backward and central difference

You forget to divide the differences by the time step (dt) dt = 0.02 for j=1:101 xb=-1+(j-1)*dt; xbb=-1+(j-2)*dt; ...

How to do forward, backward and central difference

You forget to divide the differences by the time step (dt) dt = 0.02 for j=1:101 xb=-1+(j-1)*dt; xbb=-1+(j-2)*dt; ...

1 giorno ago | 1

| accepted

Answered

How to generate random matrix from another one?

A is your input matrix Ashuffle = reshape(A(randperm(numel(A))),size(A))

How to generate random matrix from another one?

A is your input matrix Ashuffle = reshape(A(randperm(numel(A))),size(A))

1 giorno ago | 0

Answered

Specific pseudo-randomised number generator.

n = 2*ones(2,50); for k=1:2 p=randperm(50,32); % you might randomize 32 as well (must be even number in [0,50]); n(k,...

Specific pseudo-randomised number generator.

n = 2*ones(2,50); for k=1:2 p=randperm(50,32); % you might randomize 32 as well (must be even number in [0,50]); n(k,...

1 giorno ago | 1

| accepted

Answered

How to create an n by n wilkinson matrix using diag

n = 10; W = spdiags([n:-1:1; n*ones(1,n)]',[0 1],n,n);

How to create an n by n wilkinson matrix using diag

n = 10; W = spdiags([n:-1:1; n*ones(1,n)]',[0 1],n,n);

1 giorno ago | 0

| accepted

Answered

Using ALLCOMB for unknown number of vectors

Create a CELL array, and get rid of the method of naming your variables with number 1,2,.... C = {A1, A2, A3, ..., AN} B = all...

Using ALLCOMB for unknown number of vectors

Create a CELL array, and get rid of the method of naming your variables with number 1,2,.... C = {A1, A2, A3, ..., AN} B = all...

2 giorni ago | 2

Answered

Check if a set of coordinates are on a line

xy=[x(:)';y(:)']; criteriatol = 0.01; % adjust to your need, smaller means stricter line test s = svd(xy-mean(xy,2)); islin...

Check if a set of coordinates are on a line

xy=[x(:)';y(:)']; criteriatol = 0.01; % adjust to your need, smaller means stricter line test s = svd(xy-mean(xy,2)); islin...

2 giorni ago | 1

| accepted

Answered

Convolution of two log normal distributions

LOGNORMAL is defined on (0,Inf) not (-Inf,Inf) P = integral2(fun,0,t - 'x',0,inf,'RelTol',1e-12,'AbsTol',1e-12) returns correc...

Convolution of two log normal distributions

LOGNORMAL is defined on (0,Inf) not (-Inf,Inf) P = integral2(fun,0,t - 'x',0,inf,'RelTol',1e-12,'AbsTol',1e-12) returns correc...

2 giorni ago | 0

Answered

find a column vector such that the determinant of a matrix A is non-zero?

A8 = [1 0 0 0 0 0 1 0; 0 1 0 0 0 0 0 1; 0 0 1 0 0 0 1 0; 0 0 0 1 0 0 0 1 ; 0 0 0 0 1 0 1 0; 0 0 0 0 0 1 0 1] ij=nchoosek...

find a column vector such that the determinant of a matrix A is non-zero?

A8 = [1 0 0 0 0 0 1 0; 0 1 0 0 0 0 0 1; 0 0 1 0 0 0 1 0; 0 0 0 1 0 0 0 1 ; 0 0 0 0 1 0 1 0; 0 0 0 0 0 1 0 1] ij=nchoosek...

2 giorni ago | 0

| accepted

Answered

Divide an array in n different arrays

V = [1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 3 3 3 3 3 3 3 5 5 5 5 5 5 5 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2...

Divide an array in n different arrays

V = [1 1 1 1 1 1 6 6 6 6 6 6 6 6 6 3 3 3 3 3 3 3 5 5 5 5 5 5 5 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2...

3 giorni ago | 0

| accepted

Answered

How to fill interior as different color

Fill the hole with imfill Next you can color your integer image by defining the appropriate colormap % Generate test image con...

How to fill interior as different color

Fill the hole with imfill Next you can color your integer image by defining the appropriate colormap % Generate test image con...

3 giorni ago | 1

| accepted

Answered

How to do a matrix like this??

(1:10).^((1:3)') or on older MATLAB bsxfun(@power,1:10,(1:3)')

How to do a matrix like this??

(1:10).^((1:3)') or on older MATLAB bsxfun(@power,1:10,(1:3)')

4 giorni ago | 0

| accepted

Answered

Linear programming, interested in only 1 variable

If you want to minimize x1 under A*x <= b f = zeros(size(x)); f(1) = 1; x = linprog(f, A, b); (x2,...,xn) is not meaningless...

Linear programming, interested in only 1 variable

If you want to minimize x1 under A*x <= b f = zeros(size(x)); f(1) = 1; x = linprog(f, A, b); (x2,...,xn) is not meaningless...

4 giorni ago | 2

| accepted

Answered

What is the difference between using conv function and manual coding method using MATLAB?

Your twin brother/sister/class mate is faster, he/she asked the same question earlier. Don't copy the same answer, your teacher...

What is the difference between using conv function and manual coding method using MATLAB?

Your twin brother/sister/class mate is faster, he/she asked the same question earlier. Don't copy the same answer, your teacher...

4 giorni ago | 0

Answered

Find the cell index in a nested cell array, corresponding to a string (by using strcmp)

A{1} = { ... {'Up' } {'Down' } {'Left' } {'Right'} {'BLUE'} {'1' } {'7' } {'1' } {'8' } ...

Find the cell index in a nested cell array, corresponding to a string (by using strcmp)

A{1} = { ... {'Up' } {'Down' } {'Left' } {'Right'} {'BLUE'} {'1' } {'7' } {'1' } {'8' } ...

4 giorni ago | 1

Answered

Binary floating point Representation in Matlab

To overcome the limitation of dec2bin at 52 bits A=[ 0.1900 -0.0300 -0.1300 0 0.1500 -0.0700 0.0500 0.1600 -0.2500 -0.1900]...

Binary floating point Representation in Matlab

To overcome the limitation of dec2bin at 52 bits A=[ 0.1900 -0.0300 -0.1300 0 0.1500 -0.0700 0.0500 0.1600 -0.2500 -0.1900]...

4 giorni ago | 1

Answered

1d Convolution using Matlab's conv() function

Ba Ba Black Sheep wrote len(pad) = floor(len(v) / 2) Actually the above is wrong, In case CONV using with of 'same' option, t...

1d Convolution using Matlab's conv() function

Ba Ba Black Sheep wrote len(pad) = floor(len(v) / 2) Actually the above is wrong, In case CONV using with of 'same' option, t...

4 giorni ago | 0

| accepted

Answered

Convolution Computations results for a system response.

You make few mistakes, indexing and flipping (see careful conv documentation, the subtility is there, though TMW never mention w...

Convolution Computations results for a system response.

You make few mistakes, indexing and flipping (see careful conv documentation, the subtility is there, though TMW never mention w...

4 giorni ago | 0

| accepted

Answered

Find Common elements between any two columns in each matrix

Not sure but keyNeuronMat1(1:10,1:4) & keyNeuronMat2(1:10,5:8) Give you common neurons/groups.

Find Common elements between any two columns in each matrix

Not sure but keyNeuronMat1(1:10,1:4) & keyNeuronMat2(1:10,5:8) Give you common neurons/groups.

5 giorni ago | 0

| accepted

Answered

How to display all decimal numbers for floating numbers?

Try this fprintf('num1+num2 = %1.16g\n',adding_num1_and_num2)

How to display all decimal numbers for floating numbers?

Try this fprintf('num1+num2 = %1.16g\n',adding_num1_and_num2)

5 giorni ago | 0

| accepted

Answered

randomly divide vector into 2 parts.

For the record, here is how I would do: n = size(index_rating,1); i = randperm(n,round(training_data*n)); dataTraining = in...

randomly divide vector into 2 parts.

For the record, here is how I would do: n = size(index_rating,1); i = randperm(n,round(training_data*n)); dataTraining = in...

5 giorni ago | 2

Answered

Conditioning bivariate gaussian distribution

There a few issues with your code. First INTEGRAL is integration of a scalar function, you cannot integrate a vector function. ...

Conditioning bivariate gaussian distribution

There a few issues with your code. First INTEGRAL is integration of a scalar function, you cannot integrate a vector function. ...

5 giorni ago | 0

| accepted

Answered

randomly divide vector into 2 parts.

Always post complete code that can run. don't less us geuss what is the size/class of the inputs First assumption: non_zero_ent...

randomly divide vector into 2 parts.

Always post complete code that can run. don't less us geuss what is the size/class of the inputs First assumption: non_zero_ent...

5 giorni ago | 1

Answered

Filling area between more curves

Change accordingly to suit your need. tt = linspace(0,2*pi,361); xy = [2*cos(tt); 4*sin(tt)]; close all hold on pl...

Filling area between more curves

Change accordingly to suit your need. tt = linspace(0,2*pi,361); xy = [2*cos(tt); 4*sin(tt)]; close all hold on pl...

5 giorni ago | 3

| accepted

Answered

how to change axis of a matix?

load('testdata.mat'); Ufun = @(X,Y,Z) X; Vfun = @(X,Y,Z) Y./(Z+200); [X,Y,Z] = ndgrid(x,y,z); U = Ufun(X,Y,Z); V = Vfun...

how to change axis of a matix?

load('testdata.mat'); Ufun = @(X,Y,Z) X; Vfun = @(X,Y,Z) Y./(Z+200); [X,Y,Z] = ndgrid(x,y,z); U = Ufun(X,Y,Z); V = Vfun...

5 giorni ago | 0

| accepted

Answered

how to find rows and columns without using size

[numel(prod(A,2)) numel(prod(A,1))] % prod instead of sum for a change

how to find rows and columns without using size

[numel(prod(A,2)) numel(prod(A,1))] % prod instead of sum for a change

6 giorni ago | 0

Answered

how to find rows and columns without using size

for 2D array p=numel(A); if p==0 try r = A(1,:); n = 0; m = numel(A*zeros(0,1)); catch ...

how to find rows and columns without using size

for 2D array p=numel(A); if p==0 try r = A(1,:); n = 0; m = numel(A*zeros(0,1)); catch ...

6 giorni ago | 0

Answered

how to assign the equality relationship for the elements symmetry to the diagnoal of a matrix

% random test matrix A = rand(4) % symmetrize of A by copying the lower part to upper part B = tril(A)+tril(A,-1).' for ...

how to assign the equality relationship for the elements symmetry to the diagnoal of a matrix

% random test matrix A = rand(4) % symmetrize of A by copying the lower part to upper part B = tril(A)+tril(A,-1).' for ...

6 giorni ago | 0

| accepted

Answered

How to add two values to a matrix each five values of that matrix in order to have a new matrix?

XY = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15]: r = ones(size(XY)); r(5:5:end) = 3; XYZ = repelem(XY,r) Note if ...

How to add two values to a matrix each five values of that matrix in order to have a new matrix?

XY = [1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15]: r = ones(size(XY)); r(5:5:end) = 3; XYZ = repelem(XY,r) Note if ...

6 giorni ago | 2

Answered

What happened to the figure toolbar in R2018b? Why is it an axes toolbar? How can I put the buttons back?

Duplicate my poste here For R2019b all the tricks found previously no longer work. I found this one does the trick set(groot,...

What happened to the figure toolbar in R2018b? Why is it an axes toolbar? How can I put the buttons back?

Duplicate my poste here For R2019b all the tricks found previously no longer work. I found this one does the trick set(groot,...

6 giorni ago | 1