Answered

Shortest path in a 2d matrix

%W=[ 1 2 3; % 4 5 6; % 7 8 9 ] W = randi(9,5,5) % Build the 4-connected graph [m, n] = size(W); [i, j] = ndgrid(1:m,1:n)...

Shortest path in a 2d matrix

%W=[ 1 2 3; % 4 5 6; % 7 8 9 ] W = randi(9,5,5) % Build the 4-connected graph [m, n] = size(W); [i, j] = ndgrid(1:m,1:n)...

alrededor de 23 horas ago | 1

Answered

Selecting a "random" element from an array with each element having it's own weighting

A=[1,2,3,4]; p=[10 20 30 40]; c=cumsum(p); [~,r]=histc(rand(1,1e6),[0 c/c(end)]); % generate 1e6 numbers r=A(r); % Chec...

Selecting a "random" element from an array with each element having it's own weighting

A=[1,2,3,4]; p=[10 20 30 40]; c=cumsum(p); [~,r]=histc(rand(1,1e6),[0 c/c(end)]); % generate 1e6 numbers r=A(r); % Chec...

1 día ago | 1

| accepted

Answered

A QR complexity question

The O(n^3) is number of flops, which is not proportional to tic/toc. You time also RANDN Calling QR has overhead that is signi...

A QR complexity question

The O(n^3) is number of flops, which is not proportional to tic/toc. You time also RANDN Calling QR has overhead that is signi...

2 días ago | 2

| accepted

Answered

How to Solve this Big System of Equations

Possible causes: your matrix is wrongly constructed you forget to include proper boundary conditions you forget to add condit...

How to Solve this Big System of Equations

Possible causes: your matrix is wrongly constructed you forget to include proper boundary conditions you forget to add condit...

2 días ago | 1

| accepted

Answered

fill matrix with all options of successive, increasing numbers 1-5

p = 5; n = 12; j = nchoosek(2:n,p-1); m = size(j,1); % == nchoosek(n-1,p-1) == 330 and not 96 i = repmat((1:m)',1,p-1); A...

fill matrix with all options of successive, increasing numbers 1-5

p = 5; n = 12; j = nchoosek(2:n,p-1); m = size(j,1); % == nchoosek(n-1,p-1) == 330 and not 96 i = repmat((1:m)',1,p-1); A...

2 días ago | 1

| accepted

Answered

How do I find a D matrix that satisfies [K]*inv(M)*[D]==[D]*inv(M)*[K] ?

You have homogeneous linear equation, the entire null space of operator (D considered as input) K*inv(M)*D-D*inv(M)*K (dimensi...

How do I find a D matrix that satisfies [K]*inv(M)*[D]==[D]*inv(M)*[K] ?

You have homogeneous linear equation, the entire null space of operator (D considered as input) K*inv(M)*D-D*inv(M)*K (dimensi...

2 días ago | 1

Answered

Remove overlapping intervals from two array intervals without using a loop

You might interest to use my interval-merging FEX

Remove overlapping intervals from two array intervals without using a loop

You might interest to use my interval-merging FEX

4 días ago | 0

Answered

Plotting a smooth curve from points

Direct analytic method using piecewise cublic polynomial. The curve is first-order differentiable, but not second order differen...

Plotting a smooth curve from points

Direct analytic method using piecewise cublic polynomial. The curve is first-order differentiable, but not second order differen...

4 días ago | 1

| accepted

Answered

Plotting a smooth curve from points

No extra points needed (but you might add to twist the shape of the curve in the first and last interval), Spline order >= 8th ...

Plotting a smooth curve from points

No extra points needed (but you might add to twist the shape of the curve in the first and last interval), Spline order >= 8th ...

4 días ago | 1

Answered

How to calculate the volume enclosed by a set of XYZ points in 3D?

V is the volume between the plane x-y (z==0) and the surface z(x,y) from your data. If you want the volume of the data after su...

How to calculate the volume enclosed by a set of XYZ points in 3D?

V is the volume between the plane x-y (z==0) and the surface z(x,y) from your data. If you want the volume of the data after su...

5 días ago | 1

| accepted

Answered

How to triangulate a non-convex ordered set of points?

I recommednd this Mesh2D FEX

How to triangulate a non-convex ordered set of points?

I recommednd this Mesh2D FEX

5 días ago | 0

Answered

Vectorizing issue in MATLAB

It is in general not possible to vectorize sequential calculation like yours.

Vectorizing issue in MATLAB

It is in general not possible to vectorize sequential calculation like yours.

7 días ago | 0

| accepted

Answered

How to find out a smallest sub-matrix B from a sparse matrix A which has the equal rank and # of non-zero columns?

Done, B=A (so all rows of A) meets your requirement >> A = [ 1 -1 0 0 0 0 0 0 0 1 ...

How to find out a smallest sub-matrix B from a sparse matrix A which has the equal rank and # of non-zero columns?

Done, B=A (so all rows of A) meets your requirement >> A = [ 1 -1 0 0 0 0 0 0 0 1 ...

7 días ago | 0

| accepted

Answered

Converting a 3D Matrix to multiple 2D matrices

Assuming A is array 1000 x 1000 x 40 C = num2cell(A,[1 2]);

Converting a 3D Matrix to multiple 2D matrices

Assuming A is array 1000 x 1000 x 40 C = num2cell(A,[1 2]);

11 días ago | 1

| accepted

Answered

Multiply all pages of a matrix

AFAIK there is no alternative way in general; unless your matrices has special property that can use some simplification.

Multiply all pages of a matrix

AFAIK there is no alternative way in general; unless your matrices has special property that can use some simplification.

13 días ago | 0

| accepted

Answered

Using addpath on Compiled Code

I can't see addpath in your snip of code. When you compile the app, all the source mfiles used by you app MUST be found by depe...

Using addpath on Compiled Code

I can't see addpath in your snip of code. When you compile the app, all the source mfiles used by you app MUST be found by depe...

13 días ago | 0

Answered

Matlab interpolation between two surfaces

Assuming your two original surfaces are z1 and z2, juts pick w scalar in (0,1) interval, zinterp = (1-w)*z1 + w*z2; If w == 0 ...

Matlab interpolation between two surfaces

Assuming your two original surfaces are z1 and z2, juts pick w scalar in (0,1) interval, zinterp = (1-w)*z1 + w*z2; If w == 0 ...

13 días ago | 0

Answered

Matlab executable not running on remote access files

"I would like to change the directories for reading and writing theses files." IIRC the cd command is non effective in deployed...

Matlab executable not running on remote access files

"I would like to change the directories for reading and writing theses files." IIRC the cd command is non effective in deployed...

13 días ago | 0

Question

Answers editor seems to be broken

I can't see the editor tool in some PC display config + Firefox After a simple view of the thread it ask me as if I would edit ...

14 días ago | 1 answer | 0

Question

Is FORMAT DEBUG still any useful?

Can someone has an explanation for this (R2020B) clear clc x=1; y=x; x=x+1; format debug y x that produces y = ...

15 días ago | 1 answer | 1

Answered

Two linear equation with absolute value equation

Correct minimum norm solution is xmin = 90.0000 -40.0000 5.0000 5.0000 normxmin = 98.7421 obtain...

Two linear equation with absolute value equation

Correct minimum norm solution is xmin = 90.0000 -40.0000 5.0000 5.0000 normxmin = 98.7421 obtain...

15 días ago | 1

| accepted

Answered

Rearranging a 512x64 matrix into a 32x1024 matrix

% Assuming A is your input matrix of size 512 x 64 % such as % A=reshape(1:512*64,64,512)'; B = reshape(permute(reshape(A,[...

Rearranging a 512x64 matrix into a 32x1024 matrix

% Assuming A is your input matrix of size 512 x 64 % such as % A=reshape(1:512*64,64,512)'; B = reshape(permute(reshape(A,[...

15 días ago | 1

| accepted

Answered

generate random number with total sum is 10

For the case of more generic sum of n variables Xi is equal to 1. If the apriori distribution is supposed to be uniform density...

generate random number with total sum is 10

For the case of more generic sum of n variables Xi is equal to 1. If the apriori distribution is supposed to be uniform density...

15 días ago | 1

Answered

Is fmincon appropriate for optimizing vector-valued optimization variables (scalar obj. function)?

Yes fmincon supposes to handle optimization problems on objective function that depends on vector of real values. There is no re...

Is fmincon appropriate for optimizing vector-valued optimization variables (scalar obj. function)?

Yes fmincon supposes to handle optimization problems on objective function that depends on vector of real values. There is no re...

15 días ago | 0

| accepted

Answered

How do I map array values on a logical array

Result = zeros(size(B)); Result(B==1)=A

How do I map array values on a logical array

Result = zeros(size(B)); Result(B==1)=A

16 días ago | 1

Answered

Find the line where 2 planes intersect

% Planes implicit equations are: % a1*x + b1*y + c1*z = d1; % a2*x + b2*y + c2*z = d2; % a1 = 256; b1=0; c1=0; d1=0; ...

Find the line where 2 planes intersect

% Planes implicit equations are: % a1*x + b1*y + c1*z = d1; % a2*x + b2*y + c2*z = d2; % a1 = 256; b1=0; c1=0; d1=0; ...

16 días ago | 1

| accepted

Answered

subsref works as not expected

I knew it for sometime: subsref never work to emulate comma list (not sure if it's documented), because a non trivial comma list...

subsref works as not expected

I knew it for sometime: subsref never work to emulate comma list (not sure if it's documented), because a non trivial comma list...

16 días ago | 0

| accepted

Answered

Quadratic-Equation-Constrained Optimization

There is https://www.mathworks.com/help/optim/ug/coneprog.html but only for linear objective function. You migh iterate on b...

Quadratic-Equation-Constrained Optimization

There is https://www.mathworks.com/help/optim/ug/coneprog.html but only for linear objective function. You migh iterate on b...

16 días ago | 0

| accepted

Answered

Resize and sum a matrix

If you isist on "resize" array1 =[1 2 3 4 5 6 7 8 9 10 11 12 13 ...

Resize and sum a matrix

If you isist on "resize" array1 =[1 2 3 4 5 6 7 8 9 10 11 12 13 ...

17 días ago | 0

Answered

Preallocating a structure with a changing number of rows within a field

There is no need to preallocate a field (or in fact any variable) if you don't grow the array itself in a loop, which is your ca...

Preallocating a structure with a changing number of rows within a field

There is no need to preallocate a field (or in fact any variable) if you don't grow the array itself in a loop, which is your ca...

19 días ago | 0