Answered

An annoying extrapolation problem

Because you insist on using anonymous function and ugly combined expression using scalar logical expression. The trick is no lon...

An annoying extrapolation problem

Because you insist on using anonymous function and ugly combined expression using scalar logical expression. The trick is no lon...

3 months ago | 0

| accepted

Answered

Why is the result matrix “rho” of function corr (A, B) not a symmetric matrix?

As the doc describe, for example rho(2,1) is the correlation between X(:,2) and Y(:,1) rho(1,2) is the correlation between X(:...

Why is the result matrix “rho” of function corr (A, B) not a symmetric matrix?

As the doc describe, for example rho(2,1) is the correlation between X(:,2) and Y(:,1) rho(1,2) is the correlation between X(:...

3 months ago | 0

| accepted

Answered

How to efficiently index into memory and call functions within for loops

When you index a hybrid slide (j positive integer scalar) % x = ... % j = ... xidx = x(:,:,:,j,:,:) (here I take a 6D array ...

How to efficiently index into memory and call functions within for loops

When you index a hybrid slide (j positive integer scalar) % x = ... % j = ... xidx = x(:,:,:,j,:,:) (here I take a 6D array ...

3 months ago | 0

| accepted

Answered

is there a way to perform this task w/o using loops?

You might consider store in table instead NOTE: using table would be more convenient to access data, not necessary faster p.va...

is there a way to perform this task w/o using loops?

You might consider store in table instead NOTE: using table would be more convenient to access data, not necessary faster p.va...

3 months ago | 1

Answered

How can I stabilize the matrix left division (i.e. "\")?

Try pinv, lsqminnorm it can stabilize somewhat the inversion with (near) singular matrix. Both bave a tolerance argument to tune...

How can I stabilize the matrix left division (i.e. "\")?

Try pinv, lsqminnorm it can stabilize somewhat the inversion with (near) singular matrix. Both bave a tolerance argument to tune...

3 months ago | 0

Answered

square matrix containing Chebyshev polynomials becomes singular when its size becomes greater than a certain value

That is exactky what I have suggested in my answer: use the Chebyschev nodes t0 = 0; tf = 4; N = 75; syms x h = chebyshevT(...

square matrix containing Chebyshev polynomials becomes singular when its size becomes greater than a certain value

That is exactky what I have suggested in my answer: use the Chebyschev nodes t0 = 0; tf = 4; N = 75; syms x h = chebyshevT(...

3 months ago | 0

Answered

square matrix containing Chebyshev polynomials becomes singular when its size becomes greater than a certain value

If you select discrete points d the Chebychev nodes see definition wiki, and not uniform, it will become well posed.

square matrix containing Chebyshev polynomials becomes singular when its size becomes greater than a certain value

If you select discrete points d the Chebychev nodes see definition wiki, and not uniform, it will become well posed.

3 months ago | 0

Answered

interpolate a 2D map (array) of density samples and preserve the total ?

Use trapz for the integration (not sum), it should match (up to round off) with linear interpolation and interger subsamping fo...

interpolate a 2D map (array) of density samples and preserve the total ?

Use trapz for the integration (not sum), it should match (up to round off) with linear interpolation and interger subsamping fo...

3 months ago | 0

Question

xlabel/ylabel 'HorizontalAlignment' issue

I don't understand the 'HorizontalAlignment' of the text labels. It is not centered (when the figure has different size than the...

3 months ago | 1 answer | 2

Answered

Coefficents of piecewise polynomial in matlab

Similar answer as here points = [1 0 -1 0 1;0 1 0 -1 0]; pp = cscvn(points) m = pp.dim; p = pp.pieces; %D = diff(poi...

Coefficents of piecewise polynomial in matlab

Similar answer as here points = [1 0 -1 0 1;0 1 0 -1 0]; pp = cscvn(points) m = pp.dim; p = pp.pieces; %D = diff(poi...

3 months ago | 0

Answered

cscvn of a function, coefficients and breaks

This is how to use pp m = 2; n = 5; % 25 in the original question points = rand(m,n); pp = cscvn(points) m = pp.dim; p =...

cscvn of a function, coefficients and breaks

This is how to use pp m = 2; n = 5; % 25 in the original question points = rand(m,n); pp = cscvn(points) m = pp.dim; p =...

3 months ago | 0

Answered

How to index two vectors together

There is FEX, and fast if you have compiler and compile the mex file. https://www.mathworks.com/matlabcentral/fileexchange/2985...

How to index two vectors together

There is FEX, and fast if you have compiler and compile the mex file. https://www.mathworks.com/matlabcentral/fileexchange/2985...

3 months ago | 0

Answered

The difference between performing the fft2 and the convolution

Use this function, it will perform the convolution using fft method rightly https://www.mathworks.com/matlabcentral/fileexchang...

The difference between performing the fft2 and the convolution

Use this function, it will perform the convolution using fft method rightly https://www.mathworks.com/matlabcentral/fileexchang...

3 months ago | 0

Answered

How can I rotate the axes' labels parallel to the orientation of the axes?

Try this (the letters of label are rotated but the aspect ratio remain constant so they can be read easily but are not look like...

How can I rotate the axes' labels parallel to the orientation of the axes?

Try this (the letters of label are rotated but the aspect ratio remain constant so they can be read easily but are not look like...

3 months ago | 0

| accepted

Answered

Compact way to calculate the centroid of a boundary of a set of points

@Sim The area of the polygonal (A in the book) is sum(A)/2 in Jan code. So sum(A)*3 in Jan's code is equal to 6*area. They are...

Compact way to calculate the centroid of a boundary of a set of points

@Sim The area of the polygonal (A in the book) is sum(A)/2 in Jan code. So sum(A)*3 in Jan's code is equal to 6*area. They are...

3 months ago | 0

Answered

Mex function Implementation for nested-functions

you did not include operation.c in mex command

Mex function Implementation for nested-functions

you did not include operation.c in mex command

3 months ago | 2

| accepted

Answered

Strange warning how to interpret it?

Fixed with update 4 https://www.mathworks.com/support/bugreports/3114312

Strange warning how to interpret it?

Fixed with update 4 https://www.mathworks.com/support/bugreports/3114312

3 months ago | 2

| accepted

Answered

Compute only a few entries of a big matrix product

It will not store the result in 2D matrix but 3D array. I hope you can switch to this format of storage. x=rand(10000,10); k =...

Compute only a few entries of a big matrix product

It will not store the result in 2D matrix but 3D array. I hope you can switch to this format of storage. x=rand(10000,10); k =...

3 months ago | 0

| accepted

Answered

Matrix addition only to elements equal to zero

C=B; B0 = B==0; C(B0)=A(B0);

Matrix addition only to elements equal to zero

C=B; B0 = B==0; C(B0)=A(B0);

3 months ago | 0

| accepted

Answered

Code gets stuck loading when I try to run it.

First look of your code shows that you do this mistake: https://www.mathworks.com/help/matlab/matlab_prog/preallocating-arrays....

Code gets stuck loading when I try to run it.

First look of your code shows that you do this mistake: https://www.mathworks.com/help/matlab/matlab_prog/preallocating-arrays....

3 months ago | 0

Answered

How to efficiently calculate a weighted sum of 3 dimensional matrix through a vector in matlab

This uses matrix multiplication so it should be well optimized and fast. [m,n] = size(A, [1 2]); C = reshape(A,m*n, []) * B(:)...

How to efficiently calculate a weighted sum of 3 dimensional matrix through a vector in matlab

This uses matrix multiplication so it should be well optimized and fast. [m,n] = size(A, [1 2]); C = reshape(A,m*n, []) * B(:)...

3 months ago | 2

| accepted

Answered

Matrix inverse in objective function

The inv() is not supported by optimization expression see https://www.mathworks.com/help/optim/ug/supported-operations-on-optimi...

Matrix inverse in objective function

The inv() is not supported by optimization expression see https://www.mathworks.com/help/optim/ug/supported-operations-on-optimi...

3 months ago | 0

| accepted

Answered

Find all possible combinations of numbers with a specific array length

char(dec2base(0:4^12-1,4)+('A'-'0'))

Find all possible combinations of numbers with a specific array length

char(dec2base(0:4^12-1,4)+('A'-'0'))

3 months ago | 1

Answered

Order of code execution seems weird

%% Function in app.PlotSetup function printProcess(app, message) app.StatusEditField.BackgroundColor = app.yellow; app.Status...

Order of code execution seems weird

%% Function in app.PlotSetup function printProcess(app, message) app.StatusEditField.BackgroundColor = app.yellow; app.Status...

3 months ago | 1

Answered

how to use plot to draw a minor arc in matlab without calculating the angle range?

% Generate A, B, C, C is the center and A B are two points on circle r = rand(); C = randn(2,1); phi1 = 2*pi*rand; A = C + r...

how to use plot to draw a minor arc in matlab without calculating the angle range?

% Generate A, B, C, C is the center and A B are two points on circle r = rand(); C = randn(2,1); phi1 = 2*pi*rand; A = C + r...

3 months ago | 1

Answered

Multipilication of N-dimension array

D = rand(3, 3, 3); rotm1 = rand(3, 3, 2); for num=1:size(rotm1,3) for i=1:size(D,3) res(:,:,i,num)=rotm1(:,:...

Multipilication of N-dimension array

D = rand(3, 3, 3); rotm1 = rand(3, 3, 2); for num=1:size(rotm1,3) for i=1:size(D,3) res(:,:,i,num)=rotm1(:,:...

3 months ago | 1

Answered

Why does C{1}(1) work but C(1){1} results in an invalid array index error in MATLAB?

"I would like to understand the rationale behind MATLAB's requirement for parentheses indexing to appear last in an indexing exp...

Why does C{1}(1) work but C(1){1} results in an invalid array index error in MATLAB?

"I would like to understand the rationale behind MATLAB's requirement for parentheses indexing to appear last in an indexing exp...

4 months ago | 0

Answered

How can I produce this matrix?

m=6 n=3 j=randperm(m,n-1); A=accumarray([2:n;j]',1,[n,m]); A(1,setdiff(1:end,j))=1

How can I produce this matrix?

m=6 n=3 j=randperm(m,n-1); A=accumarray([2:n;j]',1,[n,m]); A(1,setdiff(1:end,j))=1

4 months ago | 1

| accepted

Answered

Implicit expansion for griddedInterpolant

You can do your own extension as showed here https://www.mathworks.com/matlabcentral/answers/2043017-bilinear-interpolation-fas...

Implicit expansion for griddedInterpolant

You can do your own extension as showed here https://www.mathworks.com/matlabcentral/answers/2043017-bilinear-interpolation-fas...

4 months ago | 0

Answered

Linking Matlab Libraries to Mingw for Another C++ Program

You need https://www.mathworks.com/products/matlab-compiler-sdk.html

Linking Matlab Libraries to Mingw for Another C++ Program

You need https://www.mathworks.com/products/matlab-compiler-sdk.html

4 months ago | 0