Community Profile

# Matt J

##### Last seen: Today
6,445 total contributions since 2009

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.

#### Matt J's Badges

View details...

Contributions in
View by

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); ...

22 hours ago | 0

| accepted

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 ...

1 day ago | 0

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);

1 day ago | 0

| accepted

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...

2 days ago | 1

| accepted

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(...

4 days ago | 0

| accepted

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 )

5 days ago | 0

| accepted

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 ...

5 days ago | 0

| accepted

Get the diagonal without calculating the explicit matrix
Assuming B*C results in a square matrix, diagonal=sum(B.' .* C, 1);

6 days ago | 1

| accepted

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(:));...

6 days ago | 2

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 ...

6 days ago | 1

| accepted

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-...

6 days ago | 1

| accepted

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 ...

9 days ago | 0

| accepted

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...

11 days ago | 0

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;

12 days ago | 0

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;

12 days ago | 0

| accepted

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...

13 days ago | 0

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

13 days ago | 0

How to quickly find the first non-zero element without iterations in all columns in a sparse matrix?
[~,result]=max(logical(A),[],1);

13 days ago | 0

| accepted

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...

14 days ago | 0

| accepted

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; ...

15 days ago | 0

| accepted

Submitted

PROB2MATRICES: A selective version of prob2struct
Obtains matrices for select parts of an optimization problem from problem-based description.

15 days ago | 10 downloads |

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...

16 days ago | 0

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...

16 days ago | 0

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

17 days ago | 0

| accepted

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...

19 days ago | 0

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...

19 days ago | 0

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...

19 days ago | 0

and my objectif function is very sensible in a way that if i change one coefficient value by 0.0001, i'll get inf as a results (...

19 days ago | 0

| accepted

Genetic algorithm constraints/optimization toolbox
You need to write your fitness function and all of your constraints in terms of 12 unknowns. The constraint matrices must be wri...

20 days ago | 0