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

Max of vector in higher dimensional array subject to constraints

N=ndims(A); %A is the given matrix z=size(A,N); idx=reshape(1:z, [ones(1,N-1),z] ) < constraint; %requires R2016b or h...

Max of vector in higher dimensional array subject to constraints

N=ndims(A); %A is the given matrix z=size(A,N); idx=reshape(1:z, [ones(1,N-1),z] ) < constraint; %requires R2016b or h...

1 hour ago | 0

Answered

How to generate random integer from 1 to N except some integers in between?

No loops required, N=10; b=3; M=5; %example data list=setdiff(1:N,b); selection=list(randperm(N-1,M)) %result

How to generate random integer from 1 to N except some integers in between?

No loops required, N=10; b=3; M=5; %example data list=setdiff(1:N,b); selection=list(randperm(N-1,M)) %result

2 hours ago | 1

Answered

Matrix consisting of sub-elements of another matrix

By indexing,e.g., >> x = [ 1 2 3 4 5 6 7 8 9]*10; >> y=x([1,2,4,5,9]) y = 10 20 40 50 90

Matrix consisting of sub-elements of another matrix

By indexing,e.g., >> x = [ 1 2 3 4 5 6 7 8 9]*10; >> y=x([1,2,4,5,9]) y = 10 20 40 50 90

2 hours ago | 0

| accepted

Answered

How to create an object using class name

function newObj = createNewObject(obj) newObj = feval( class(obj) ); end

How to create an object using class name

function newObj = createNewObject(obj) newObj = feval( class(obj) ); end

6 hours ago | 0

Answered

Adding just one line in my code slows the GPU.

Pre-allocate on the GPU. Also, pre-compute things on the GPU that are easily vectorized and don't depend on r. R=gpuArray.zeros...

Adding just one line in my code slows the GPU.

Pre-allocate on the GPU. Also, pre-compute things on the GPU that are easily vectorized and don't depend on r. R=gpuArray.zeros...

7 hours ago | 0

Answered

Converting a row to diagonal matrix

Did some guessing as to what you meant, but I think this is what you want: A=tril(true(16),-1); B=double(A); B(A)=rowdata; ...

Converting a row to diagonal matrix

Did some guessing as to what you meant, but I think this is what you want: A=tril(true(16),-1); B=double(A); B(A)=rowdata; ...

8 hours ago | 0

Answered

Find minimum of a 15x100 and return in a vector of 1x100. is this possible?

The names of the variables you wrote to the table Min_AS,Med_AS,Max_AS are different from the original variable names you show...

Find minimum of a 15x100 and return in a vector of 1x100. is this possible?

The names of the variables you wrote to the table Min_AS,Med_AS,Max_AS are different from the original variable names you show...

9 hours ago | 0

Answered

Solve equations in a loop with fsolve

Your equations are quadratic and therefore generally have two solutions, s. Fsolve cannot find them both for you. Why aren't you...

Solve equations in a loop with fsolve

Your equations are quadratic and therefore generally have two solutions, s. Fsolve cannot find them both for you. Why aren't you...

12 hours ago | 0

Answered

Any idea how to do and represent ttest results on box plot?

Usually, I just overlay them in powerpoint. But if you must automate this, one not too difficult way would be to use the line co...

Any idea how to do and represent ttest results on box plot?

Usually, I just overlay them in powerpoint. But if you must automate this, one not too difficult way would be to use the line co...

1 day ago | 0

Answered

changing a group of numbers in a vector

As an example, >> cycles=[0,1,0,1,0,1]; %3 cycles >> A=repelem(cycles,3) A = Columns 1 through 16 0 0 ...

changing a group of numbers in a vector

As an example, >> cycles=[0,1,0,1,0,1]; %3 cycles >> A=repelem(cycles,3) A = Columns 1 through 16 0 0 ...

3 days ago | 0

Answered

How to replace a vector element with a value not equal the other vector values?

function sudokuRow = fillSudokuRow(sudokuRow) idx=(sudokuRow==0); sudokuRow(idx)=func(sudokuRow(~idx)); end

How to replace a vector element with a value not equal the other vector values?

function sudokuRow = fillSudokuRow(sudokuRow) idx=(sudokuRow==0); sudokuRow(idx)=func(sudokuRow(~idx)); end

3 days ago | 0

Answered

Passing parameter values found in lsqcurvefit to be initial values for parameter estimation in another function

Some possibilities, Combine the code from both fitting steps into a single script. That way you will have direct access to the ...

Passing parameter values found in lsqcurvefit to be initial values for parameter estimation in another function

Some possibilities, Combine the code from both fitting steps into a single script. That way you will have direct access to the ...

3 days ago | 0

| accepted

Question

Is there a danger in renaming a Matlab install folder

I have Matlab R2019b installed under Windows 10 in the usual place, C:\Program Files\MATLAB\R2019b but I would now like to ren...

3 days ago | 2 answers | 1

Answered

Speeding up nested for-loops when vectorization seems to fail

Getting rid of repmat (requires R2016b or later) and working with single float precision will get you some speed-up. In doubles...

Speeding up nested for-loops when vectorization seems to fail

Getting rid of repmat (requires R2016b or later) and working with single float precision will get you some speed-up. In doubles...

4 days ago | 0

Answered

Speeding up nested for-loops when vectorization seems to fail

I tend to think you should be using scatteredInterpolant rather than implementing your own interpolation routine with loops.

Speeding up nested for-loops when vectorization seems to fail

I tend to think you should be using scatteredInterpolant rather than implementing your own interpolation routine with loops.

5 days ago | 0

Answered

lsqcurvefit does not match data

Your model is clearly wrong, assuming that the given data is valid. In your current model, saturation is always 0 when displacem...

lsqcurvefit does not match data

Your model is clearly wrong, assuming that the given data is valid. In your current model, saturation is always 0 when displacem...

5 days ago | 0

| accepted

Answered

Row & Column Wise Normalisation

For a non-negative square matrix, the attached article mentions necessary and sufficient conditions (p. 3, Theorem 1) both for t...

Row & Column Wise Normalisation

For a non-negative square matrix, the attached article mentions necessary and sufficient conditions (p. 3, Theorem 1) both for t...

5 days ago | 2

| accepted

Answered

How to move programmatically existing datatip

Maybe you can use the advice here, https://www.mathworks.com/matlabcentral/answers/100545-how-can-i-programmatically-control-mo...

How to move programmatically existing datatip

Maybe you can use the advice here, https://www.mathworks.com/matlabcentral/answers/100545-how-can-i-programmatically-control-mo...

5 days ago | 1

Answered

How to solve Too many input arguments error? Error in Fminsearch (line 200) fv(:,1) = funfcn(x,varargin{:});

This fh handles should be, fh{n}= @(x)vpe(x,p,MSM(:,n),erps(:,n),n);

How to solve Too many input arguments error? Error in Fminsearch (line 200) fv(:,1) = funfcn(x,varargin{:});

This fh handles should be, fh{n}= @(x)vpe(x,p,MSM(:,n),erps(:,n),n);

6 days ago | 0

| accepted

Answered

A is a matrix of size 32*32.I want to subtract elements of each 4*4 block of A from their respective 4*4 means

out = blockproc(A,[4 4],@(x)mean(x.data(:))); result = A - repelem( out , 4,4);

A is a matrix of size 32*32.I want to subtract elements of each 4*4 block of A from their respective 4*4 means

out = blockproc(A,[4 4],@(x)mean(x.data(:))); result = A - repelem( out , 4,4);

6 days ago | 0

| accepted

Answered

Reducing repeated elements in an array by a factor

Another method, one which avoids for-loops inherent in cell2mat, V=[1,2,2,2,0,2,2,2,5,5,5,5,5,5,6,6,6]; N=3; X = cumsum...

Reducing repeated elements in an array by a factor

Another method, one which avoids for-loops inherent in cell2mat, V=[1,2,2,2,0,2,2,2,5,5,5,5,5,5,6,6,6]; N=3; X = cumsum...

6 days ago | 0

Answered

The support on here is horrible, does anyone have an api for the function calls? I'm tired of searching only to find examples of what I don't need.

Matlab Answers is a discussion forum, not a documentation browser. If you want to find documentation, start here, https://www.m...

The support on here is horrible, does anyone have an api for the function calls? I'm tired of searching only to find examples of what I don't need.

Matlab Answers is a discussion forum, not a documentation browser. If you want to find documentation, start here, https://www.m...

8 days ago | 2

Answered

How to use fimplicit with a symbolic function

Using matlabFunction, you can derive a non-symbolic version of your circle equation expression from the symbolic version, >> ci...

How to use fimplicit with a symbolic function

Using matlabFunction, you can derive a non-symbolic version of your circle equation expression from the symbolic version, >> ci...

8 days ago | 0

Answered

How can I get the elements from a matrix and use them as the coordinates in another matrix

D = C( sub2ind( size(C), W(:,1:end-1), W(:,2:end) ) ), sum(D,2)

How can I get the elements from a matrix and use them as the coordinates in another matrix

D = C( sub2ind( size(C), W(:,1:end-1), W(:,2:end) ) ), sum(D,2)

8 days ago | 0

| accepted

Answered

A class to simulate missing arguments in function calls

The main drawback is that one must always use myfeval, which is not very readable. Yet another solution, which might address th...

A class to simulate missing arguments in function calls

The main drawback is that one must always use myfeval, which is not very readable. Yet another solution, which might address th...

8 days ago | 0

Answered

Multiple selection of an array

You can use sepblockfun downloadable from here https://www.mathworks.com/matlabcentral/fileexchange/48089-separable-block-wise-...

Multiple selection of an array

You can use sepblockfun downloadable from here https://www.mathworks.com/matlabcentral/fileexchange/48089-separable-block-wise-...

8 days ago | 0

Answered

A class to simulate missing arguments in function calls

Clearly, I would have to check for each input argument to be ~isempty(), or ~isnan(), which could be another technique. However,...

A class to simulate missing arguments in function calls

Clearly, I would have to check for each input argument to be ~isempty(), or ~isnan(), which could be another technique. However,...

11 days ago | 0

| accepted

Answered

A class to simulate missing arguments in function calls

Seems to me that you can effectively accomplish what you want by defining a trivial class with no properties or methods, classd...

A class to simulate missing arguments in function calls

Seems to me that you can effectively accomplish what you want by defining a trivial class with no properties or methods, classd...

11 days ago | 0

Answered

Evaluating a complicated integral in Matlab gives NaN

Your integrand has a singularity at psi = pi/2. So perhaps try, f2(i) = integral(f1, 0, pi/2*(1-eps), 'ArrayValued', true);

Evaluating a complicated integral in Matlab gives NaN

Your integrand has a singularity at psi = pi/2. So perhaps try, f2(i) = integral(f1, 0, pi/2*(1-eps), 'ArrayValued', true);

12 days ago | 1

Answered

How to find "rectangular" corners?

Use pgonCorners from the File Exchange (Download). It applies to any convex polyhedron. numVertices=4; corners=pgonCorners(I...

How to find "rectangular" corners?

Use pgonCorners from the File Exchange (Download). It applies to any convex polyhedron. numVertices=4; corners=pgonCorners(I...

12 days ago | 1