Answered

How to calculate mean in moving cubic volume?

I know I need to use mat2cell and mean function. I don't think you do. Let's call your 3D volume, V: [ci,cj,ck]=deal(51,51,251...

How to calculate mean in moving cubic volume?

I know I need to use mat2cell and mean function. I don't think you do. Let's call your 3D volume, V: [ci,cj,ck]=deal(51,51,251...

18 days ago | 0

| accepted

Answered

I'm looking if there anyone can share with me the code of optimization with multi-objective?

The best place to look for shared code is on the File Exchange. I see there is at least one MPSO offering here, https://www.mat...

I'm looking if there anyone can share with me the code of optimization with multi-objective?

The best place to look for shared code is on the File Exchange. I see there is at least one MPSO offering here, https://www.mat...

18 days ago | 0

Answered

How to know the current input for fminsearch?

You can use an OutputFcn, https://www.mathworks.com/help/matlab/math/output-functions.html#bsgue2z or simply add a line of cod...

How to know the current input for fminsearch?

You can use an OutputFcn, https://www.mathworks.com/help/matlab/math/output-functions.html#bsgue2z or simply add a line of cod...

18 days ago | 1

| accepted

Answered

K-th order neighbors in graph

function result=distk(G,i,k) % G -graph % i - start node % k - number of steps A=adjacency(G); v=A(i,:); ...

K-th order neighbors in graph

function result=distk(G,i,k) % G -graph % i - start node % k - number of steps A=adjacency(G); v=A(i,:); ...

18 days ago | 1

| accepted

Answered

Smooth derivative of a matrix

So my question is: is there any way to smoothly connect the eigenvectors of neighbouring k points? Not in general. The eigenvec...

Smooth derivative of a matrix

So my question is: is there any way to smoothly connect the eigenvectors of neighbouring k points? Not in general. The eigenvec...

19 days ago | 0

Answered

Second order polynomial curve of best fit

It probably happens because you've chosen too arbitrary an initial guess constant=[0;0;0]. It's clear from your data that these ...

Second order polynomial curve of best fit

It probably happens because you've chosen too arbitrary an initial guess constant=[0;0;0]. It's clear from your data that these ...

19 days ago | 0

| accepted

Answered

Error - Failure in initial objective function evaluation. FSOLVE cannot continue.

Second, I'm not sure why fsolve is having trouble parsing the initial guess. This is not a separate error. fsolve is simply te...

Error - Failure in initial objective function evaluation. FSOLVE cannot continue.

Second, I'm not sure why fsolve is having trouble parsing the initial guess. This is not a separate error. fsolve is simply te...

20 days ago | 1

| accepted

Answered

can matlab find the row space and null space of a matrix?

Yes, the solution could involve the commands orth() and null().

can matlab find the row space and null space of a matrix?

Yes, the solution could involve the commands orth() and null().

20 days ago | 0

Answered

Subfunctions in optimization objective function

fmincon does not know or care about the internals of your objective function code. You can do anything there, and call whatever ...

Subfunctions in optimization objective function

fmincon does not know or care about the internals of your objective function code. You can do anything there, and call whatever ...

20 days ago | 1

| accepted

Answered

Getting meshgrid along different angles for data extraction from a matrix/image?

If you're just trying to generate shaded polygons, it would be simpler just to use impoly, e.g., x0 = 1; y0=1; x1 = 200; y1=50...

Getting meshgrid along different angles for data extraction from a matrix/image?

If you're just trying to generate shaded polygons, it would be simpler just to use impoly, e.g., x0 = 1; y0=1; x1 = 200; y1=50...

20 days ago | 0

| accepted

Answered

How can I remove the lines that are not in the cross section of the annulus?

figure(1); % add lj line to temperature profile hold on; for ii...

How can I remove the lines that are not in the cross section of the annulus?

figure(1); % add lj line to temperature profile hold on; for ii...

21 days ago | 2

| accepted

Answered

How to construct all possible combinations of points in N-dimensional space

X=[x1,x2,x3].'; Y=[y1,y2,y3].'; [I,J]=ndgrid(1:3,4*(0:N-1) ); P=[X(I(:)),Y(I(:)), J(:)]; d=pdist2(P,P);

How to construct all possible combinations of points in N-dimensional space

X=[x1,x2,x3].'; Y=[y1,y2,y3].'; [I,J]=ndgrid(1:3,4*(0:N-1) ); P=[X(I(:)),Y(I(:)), J(:)]; d=pdist2(P,P);

21 days ago | 0

Answered

how to draw the intersection of 3 3d objects?

One of these FEX submissions might be helpful, https://www.mathworks.com/matlabcentral/fileexchange/48613-surface-intersection ...

how to draw the intersection of 3 3d objects?

One of these FEX submissions might be helpful, https://www.mathworks.com/matlabcentral/fileexchange/48613-surface-intersection ...

21 days ago | 0

| accepted

Answered

How to check if object's property is read-only.

You can obtain that information from a metaclass object for the class, https://www.mathworks.com/help/matlab/matlab_oop/using-c...

How to check if object's property is read-only.

You can obtain that information from a metaclass object for the class, https://www.mathworks.com/help/matlab/matlab_oop/using-c...

21 days ago | 0

| accepted

Answered

Comparing elements in a 2d array

>> peak = [0, diff(array(1:end-1))>=0 & diff(array(2:end))<=0 , 0] peak = 0 1 0 0 0 1 0 >>...

Comparing elements in a 2d array

>> peak = [0, diff(array(1:end-1))>=0 & diff(array(2:end))<=0 , 0] peak = 0 1 0 0 0 1 0 >>...

21 days ago | 0

Answered

Improving and Optimizing Blurring Function

Using sepblockfun from the File Exchange, https://www.mathworks.com/matlabcentral/fileexchange/48089-separable-block-wise-opera...

Improving and Optimizing Blurring Function

Using sepblockfun from the File Exchange, https://www.mathworks.com/matlabcentral/fileexchange/48089-separable-block-wise-opera...

21 days ago | 1

| accepted

Answered

Nonlinear equation numerical solution

I tryed also with functions: fsolve, roots and find but were all unsuccessful. fsolve is overkill for such a simple 1D problem....

Nonlinear equation numerical solution

I tryed also with functions: fsolve, roots and find but were all unsuccessful. fsolve is overkill for such a simple 1D problem....

22 days ago | 1

Answered

How to find out zeros and their indices in a matrix?

One way is to use this FEX submission, https://www.mathworks.com/matlabcentral/fileexchange/78008-group1s H=group1s(~input(2,:...

How to find out zeros and their indices in a matrix?

One way is to use this FEX submission, https://www.mathworks.com/matlabcentral/fileexchange/78008-group1s H=group1s(~input(2,:...

22 days ago | 2

Answered

Is there a way to do these matrix vector multiplications without loops?

First, you would choose a different ordering. Instead of A = rand(m,n,4,4); v = rand(m,n,4); you would have A = rand(4,4,m,...

Is there a way to do these matrix vector multiplications without loops?

First, you would choose a different ordering. Instead of A = rand(m,n,4,4); v = rand(m,n,4); you would have A = rand(4,4,m,...

22 days ago | 1

| accepted

Answered

Optimizing systems of non-linear equation using optimvar and lsqcurvefit

Avoid sqrt so as to ensure fun is differentiable fun = @(x,xdata) [((1+4.*xdata.^2.*x(1)^2).^(-2) + x(4))./((1+4.*xdata.^2.*x(2...

Optimizing systems of non-linear equation using optimvar and lsqcurvefit

Avoid sqrt so as to ensure fun is differentiable fun = @(x,xdata) [((1+4.*xdata.^2.*x(1)^2).^(-2) + x(4))./((1+4.*xdata.^2.*x(2...

22 days ago | 0

Answered

How can I do 1D convolution on a 880*1 feature with filter size 45*1 with stride of 42?

You can create a weight matrix that computes the convolution using func2mat on the File Exchange https://www.mathworks.com/matl...

How can I do 1D convolution on a 880*1 feature with filter size 45*1 with stride of 42?

You can create a weight matrix that computes the convolution using func2mat on the File Exchange https://www.mathworks.com/matl...

24 days ago | 0

Answered

I need to maximize an objective function using genetic algorithm but i am having errors

You should not have symbolic input/output in myfitness(). ga() is a numerical solver, so the operations in myfitness() should ta...

I need to maximize an objective function using genetic algorithm but i am having errors

You should not have symbolic input/output in myfitness(). ga() is a numerical solver, so the operations in myfitness() should ta...

24 days ago | 1

| accepted

Answered

Expanding a 2D matrix to 3D

Another way, C=double(A); %A is the given matrix C(logical(A))=mod(0:nnz(A)-1,3)+1; result = cat(3, C==1, C==2, C==3)

Expanding a 2D matrix to 3D

Another way, C=double(A); %A is the given matrix C(logical(A))=mod(0:nnz(A)-1,3)+1; result = cat(3, C==1, C==2, C==3)

25 days ago | 0

| accepted

Answered

Expanding a 2D matrix to 3D

Let's call your given matrix, A, [m,n]=size(A); [I,J]=find(A); K=repmat((1:3).',1,n); result=accumarray([I,J,K(:)],tru...

Expanding a 2D matrix to 3D

Let's call your given matrix, A, [m,n]=size(A); [I,J]=find(A); K=repmat((1:3).',1,n); result=accumarray([I,J,K(:)],tru...

25 days ago | 0

Answered

Indexing for partial matrix

[upperBlob,lowerBlob]=deal(yourMatrix); upperBlob(78:end,:)=-inf; lowerBlob(1:77,:)=-inf; [imax1,jmax1]=find(upperBlob==m...

Indexing for partial matrix

[upperBlob,lowerBlob]=deal(yourMatrix); upperBlob(78:end,:)=-inf; lowerBlob(1:77,:)=-inf; [imax1,jmax1]=find(upperBlob==m...

25 days ago | 0

Answered

How to use an optimization expression if in a function?

You cannot express such an operation through the problem-based framework. If you are trying to solve a minimax problem, then you...

How to use an optimization expression if in a function?

You cannot express such an operation through the problem-based framework. If you are trying to solve a minimax problem, then you...

26 days ago | 0

| accepted

Answered

How to reflect the element above the diagonal of a matrix to the lower diagonal ?

b=triu(a)+triu(a,1).'; %the result

How to reflect the element above the diagonal of a matrix to the lower diagonal ?

b=triu(a)+triu(a,1).'; %the result

26 days ago | 0

| accepted

Answered

How to transform a ellipse to circle

If the equation for the ellipse is x.'*Q*x =1 then you simply take the cholesky decomposition of the 2x2 matrix Q, L=chol(Q)...

How to transform a ellipse to circle

If the equation for the ellipse is x.'*Q*x =1 then you simply take the cholesky decomposition of the 2x2 matrix Q, L=chol(Q)...

26 days ago | 1

Answered

Help with PARFOR function

I saw that it is possible to use PARFOR function instead of FOR to make calculs in parallel and then to save time. That is only...

Help with PARFOR function

I saw that it is possible to use PARFOR function instead of FOR to make calculs in parallel and then to save time. That is only...

27 days ago | 0

| accepted

Answered

I WANT TO KNOW WHY SO MUCH "." (dot) to define a statement, and does it mean something. Swarm.Particles(k).X ???

It means (probably) that Swarm and some of its fields are struct arrays, https://www.mathworks.com/help/matlab/matlab_prog/crea...

I WANT TO KNOW WHY SO MUCH "." (dot) to define a statement, and does it mean something. Swarm.Particles(k).X ???

It means (probably) that Swarm and some of its fields are struct arrays, https://www.mathworks.com/help/matlab/matlab_prog/crea...

27 days ago | 0