Community Profile

# Matt J

##### Last seen: Today
6.441 total contributions since 2009

Professional Interests: medical image processing, optimization algorithms

View details...

Contributions in
View by

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

etwa 21 Stunden 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 )

2 Tage ago | 0

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

2 Tage ago | 0

| accepted

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

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

2 Tage ago | 0

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

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

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

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

8 Tage 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;

9 Tage 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;

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

9 Tage 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

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

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

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

11 Tage ago | 0

| accepted

Submitted

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

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

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

13 Tage ago | 0

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

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

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

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

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

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

17 Tage ago | 0

Mathematical formulation of a operations research problem
Should be very easy with the Problem-Based Optimization Workflow.

17 Tage ago | 1

| accepted

How to find a figure's centroid inside a polyshape?
In fact Matt, anywhere within the limits is already viable for me. If so, you could use nearestvertex command to project the ce...

17 Tage ago | 1

| accepted

Integral evaluation in an alphashape
Perhaps as follows. Here, shp refers to your alphaShape object. fun=@(x,y,z) (x.^2+y.^2+z.^2).*shp.inShape(x,y,z); range=num...

17 Tage ago | 0

Max number iterations for tolerance
Call fminsearch with more output arguments to get information about how many iterations it took. x0 = [3,4]; options = optimse...

17 Tage ago | 0