Professional Interests: medical image processing, optimization algorithms

PLEASE NOTE: I do not read email sent through my author page. Please post questions about FEX submissions in their respective Comments section.

Answered

Cells and Cell vectors help?

So, as a smaller example, if n=4 and the input is this C={ [1 2] , [], [2 3 4], [] }, the output should be this, A = 1...

Cells and Cell vectors help?

So, as a smaller example, if n=4 and the input is this C={ [1 2] , [], [2 3 4], [] }, the output should be this, A = 1...

9 hours ago | 0

| accepted

Answered

How to calculate from three points the "normal" at the second point

Once you have answered David's question, the attached function should be useful. It will find the normals to all the facets of a...

How to calculate from three points the "normal" at the second point

Once you have answered David's question, the attached function should be useful. It will find the normals to all the facets of a...

1 day ago | 1

Answered

Using Groups of Rows in a Parfor Loop

As mentioned in my comment, your example does not make it clear why a loop is necessary at all. However, the reason for your dif...

Using Groups of Rows in a Parfor Loop

As mentioned in my comment, your example does not make it clear why a loop is necessary at all. However, the reason for your dif...

2 days ago | 0

| accepted

Answered

Help with non working for loop for generating a matrix

One approach is to write x,y, and A as matrix-valued anonymous functions of c, e.g., x=@(c)(4-c)./(6+c); y=@(c)10./(6+c); ...

Help with non working for loop for generating a matrix

One approach is to write x,y, and A as matrix-valued anonymous functions of c, e.g., x=@(c)(4-c)./(6+c); y=@(c)10./(6+c); ...

4 days ago | 0

| accepted

Answered

Quadratically constrained linear maximisation problem: issues with fmincon

Well, it would be interesting to know what algorithm Gurobi uses, but the issue of the objective function difference appears to ...

Quadratically constrained linear maximisation problem: issues with fmincon

Well, it would be interesting to know what algorithm Gurobi uses, but the issue of the objective function difference appears to ...

5 days ago | 0

Answered

How can I create random Co-ordinate shifts (x,y,z) that add to a displacement of 1?

[a,b,c]=sph2cart(2*pi*rand,pi*rand,1);

How can I create random Co-ordinate shifts (x,y,z) that add to a displacement of 1?

[a,b,c]=sph2cart(2*pi*rand,pi*rand,1);

5 days ago | 0

| accepted

Answered

How to constrain distance between points in optimization?

It can be set up this way, but keep in mind that this is a highly non-convex feasible set. It may be challenging to find a glob...

How to constrain distance between points in optimization?

It can be set up this way, but keep in mind that this is a highly non-convex feasible set. It may be challenging to find a glob...

5 days ago | 1

| accepted

Answered

Multidimensional operations without for loop

Q=nan(8,n); [J,K]=ndgrid(1:8,1:n); I=maxloc(K); thetaIndices=sub2ind(size(theta), I,J,K); QIndices=sub2ind(...

Multidimensional operations without for loop

Q=nan(8,n); [J,K]=ndgrid(1:8,1:n); I=maxloc(K); thetaIndices=sub2ind(size(theta), I,J,K); QIndices=sub2ind(...

8 days ago | 0

| accepted

Answered

fzero with function in matrix

syms x a=[sin(x),1;1,1]; b=[1/cos(x);1]; c=a*b; x=fzero( matlabFunction(c(1)-1) , pi/4 )

fzero with function in matrix

syms x a=[sin(x),1;1,1]; b=[1/cos(x);1]; c=a*b; x=fzero( matlabFunction(c(1)-1) , pi/4 )

9 days ago | 0

| accepted

Answered

How can i speed up my code?

Please do not provide code in the form of embedded images. It prevents us from conveniently copy/pasting relevant sections. In ...

How can i speed up my code?

Please do not provide code in the form of embedded images. It prevents us from conveniently copy/pasting relevant sections. In ...

9 days ago | 0

| accepted

Answered

Get the diagonal without calculating the explicit matrix

Assuming B*C results in a square matrix, diagonal=sum(B.' .* C, 1);

Get the diagonal without calculating the explicit matrix

Assuming B*C results in a square matrix, diagonal=sum(B.' .* C, 1);

9 days ago | 1

| accepted

Answered

Finding Area of Polygon defined by roipoly

roipoly returns a logical mask BW of the region BW = roipoly; so, its area in whole pixels would simply be area = sum(BW(:));...

Finding Area of Polygon defined by roipoly

roipoly returns a logical mask BW of the region BW = roipoly; so, its area in whole pixels would simply be area = sum(BW(:));...

9 days ago | 2

Answered

Setting nonlcon for fmincon / patternsearch as a matlabfunction

Create a wrapper function like the one below. To make it visible from the workspace where patternsearch is called, you can make ...

Setting nonlcon for fmincon / patternsearch as a matlabfunction

Create a wrapper function like the one below. To make it visible from the workspace where patternsearch is called, you can make ...

9 days ago | 1

| accepted

Answered

Use of kron with more than two matricies

One way would be to use my KronProd class https://www.mathworks.com/matlabcentral/fileexchange/25969-efficient-object-oriented-...

Use of kron with more than two matricies

One way would be to use my KronProd class https://www.mathworks.com/matlabcentral/fileexchange/25969-efficient-object-oriented-...

9 days ago | 1

| accepted

Answered

How to find a minimal number of rows in a sparse matrix to form a square sub-matrix for a given row?

If you have the Optimization Toolbox, you can try this linear programming solution: A = [ -1 1 0 0 0 0 ...

How to find a minimal number of rows in a sparse matrix to form a square sub-matrix for a given row?

If you have the Optimization Toolbox, you can try this linear programming solution: A = [ -1 1 0 0 0 0 ...

12 days ago | 0

| accepted

Answered

How to plot a single variable function with constraints

You can assign NaN to anything you don't want plotted. Example, x=linspace(0,2,1000); f=sin(x); f( 0.5<=x & x<=1)=nan; p...

How to plot a single variable function with constraints

You can assign NaN to anything you don't want plotted. Example, x=linspace(0,2,1000); f=sin(x); f( 0.5<=x & x<=1)=nan; p...

14 days ago | 0

Answered

How to quickly find the column index of the last non-zero element in all rows in a sparse matrix?

[~,idx]=max(fliplr(logical(A)),[],2); result=size(A,2)+1-idx;

How to quickly find the column index of the last non-zero element in all rows in a sparse matrix?

[~,idx]=max(fliplr(logical(A)),[],2); result=size(A,2)+1-idx;

15 days ago | 0

Answered

Create n equidistant point along a circle

theta=linspace(0,360,n+1); theta(end)=[]; x=R*cosd(theta)+x0; y=R*sind(theta)+y0;

Create n equidistant point along a circle

theta=linspace(0,360,n+1); theta(end)=[]; x=R*cosd(theta)+x0; y=R*sind(theta)+y0;

16 days ago | 0

| accepted

Answered

polyfit curve turns around near last point

Your data, when plotted alone, do not look very polynomial like. They do not even look like a function. x = [0 0 -0.0063 -0...

polyfit curve turns around near last point

Your data, when plotted alone, do not look very polynomial like. They do not even look like a function. x = [0 0 -0.0063 -0...

16 days ago | 0

Answered

How to quickly find the first non-zero element without iterations in all columns in a sparse matrix?

See this FEX submission, https://www.mathworks.com/matlabcentral/fileexchange/24641-vectorized-find-with-first-option

How to quickly find the first non-zero element without iterations in all columns in a sparse matrix?

See this FEX submission, https://www.mathworks.com/matlabcentral/fileexchange/24641-vectorized-find-with-first-option

16 days ago | 0

Answered

How to quickly find the first non-zero element without iterations in all columns in a sparse matrix?

[~,result]=max(logical(A),[],1);

How to quickly find the first non-zero element without iterations in all columns in a sparse matrix?

[~,result]=max(logical(A),[],1);

16 days ago | 0

| accepted

Answered

Use fsolve with an elliptic integral

It does not make sense to have a relational expression like, [K, E]== ellipke(m) as one of your equations, expecially one that...

Use fsolve with an elliptic integral

It does not make sense to have a relational expression like, [K, E]== ellipke(m) as one of your equations, expecially one that...

17 days ago | 0

| accepted

Answered

Unclassified variables in a parfor loop

parfor i= 1:xyend-xystart+1 .... A = zeros(nx,ny); B = A; for n=1:Nn; for m=1:Mm; ...

Unclassified variables in a parfor loop

parfor i= 1:xyend-xystart+1 .... A = zeros(nx,ny); B = A; for n=1:Nn; for m=1:Mm; ...

18 days ago | 0

| accepted

Submitted

PROB2MATRICES: A selective version of prob2struct

Obtains matrices for select parts of an optimization problem from problem-based description.

19 days ago | 10 downloads |

Answered

Should I trust solutions obtained for a nonlinear non-transcendental equation in matlab using 'fzero' function?

fzero is a numerical root finder. One doesn't expect y(x) to be exactly zero at the roots that it finds, but it should be pretty...

Should I trust solutions obtained for a nonlinear non-transcendental equation in matlab using 'fzero' function?

fzero is a numerical root finder. One doesn't expect y(x) to be exactly zero at the roots that it finds, but it should be pretty...

19 days ago | 0

Answered

How to Put Objective and Constraints functions in the same function ?

I am working on an optimization problem with non linear inequality constraints and i wish to put the objective and constraints f...

How to Put Objective and Constraints functions in the same function ?

I am working on an optimization problem with non linear inequality constraints and i wish to put the objective and constraints f...

19 days ago | 0

Answered

fmincon check gradients fail

CheckGradient uses central differences, whereas you appear to be using right handed differences. Are you certain that your const...

fmincon check gradients fail

CheckGradient uses central differences, whereas you appear to be using right handed differences. Are you certain that your const...

20 days ago | 0

| accepted

Answered

Minimising the summation of distance between two curves by placing the arc at best distance from origin

It's a non-differentiable, one dimensional cost function minimization. I would use fminbnd, https://www.mathworks.com/help/matl...

Minimising the summation of distance between two curves by placing the arc at best distance from origin

It's a non-differentiable, one dimensional cost function minimization. I would use fminbnd, https://www.mathworks.com/help/matl...

22 days ago | 0

Answered

Calling a class's static method from its metadata

or indeed a better way entirely from what I am proposing to achieve the calling of such an abstract static function on all subcl...

Calling a class's static method from its metadata

or indeed a better way entirely from what I am proposing to achieve the calling of such an abstract static function on all subcl...

23 days ago | 0

Answered

How do I feed data from a non linear constraint function to the objective function when using fmincon?

Since your unknown vector is x, your objective and constraints must be functions of x and nothing else (except known constants w...

How do I feed data from a non linear constraint function to the objective function when using fmincon?

Since your unknown vector is x, your objective and constraints must be functions of x and nothing else (except known constants w...

23 days ago | 0