Answered

lsqcurvefit add a constraint

No, you cannot supply any constraints except simple bounds with lsqcurvefit. You do need to use fmincon. Write an objective func...

lsqcurvefit add a constraint

No, you cannot supply any constraints except simple bounds with lsqcurvefit. You do need to use fmincon. Write an objective func...

14 days ago | 0

Answered

Take average of the nearest n pixels

If you have the Statistics Toolbox, you could use knnsearch, https://www.mathworks.com/help/stats/knnsearch.html

Take average of the nearest n pixels

If you have the Statistics Toolbox, you could use knnsearch, https://www.mathworks.com/help/stats/knnsearch.html

15 days ago | 0

| accepted

Answered

Parameter estimation - estimate integers only

If your objective and constraints are linear, you can use intlinprog. Otherwise, if you have the Global Optimization Toolbox, an...

Parameter estimation - estimate integers only

If your objective and constraints are linear, you can use intlinprog. Otherwise, if you have the Global Optimization Toolbox, an...

15 days ago | 0

Answered

fmincon to get 3 unknown parameters

As the error message says, your objective function must return a scalar value and does not. It returns a length 12 vector. The v...

fmincon to get 3 unknown parameters

As the error message says, your objective function must return a scalar value and does not. It returns a length 12 vector. The v...

15 days ago | 0

Answered

what is the differences between "sum(x, 3, 'omitnan')" and "nansum(x, 3)" ?

Nothing. In earlier versions of Matlab, the 'omitnan' flag wasn't available to the sum command, so you had to either use nansum ...

what is the differences between "sum(x, 3, 'omitnan')" and "nansum(x, 3)" ?

Nothing. In earlier versions of Matlab, the 'omitnan' flag wasn't available to the sum command, so you had to either use nansum ...

15 days ago | 1

Answered

Define a Non linear objective function with 2 decision variables

If you have R2109a or higher, the general set-up could be done like this. For simplicity, I demonstrate using a least squares ob...

Define a Non linear objective function with 2 decision variables

If you have R2109a or higher, the general set-up could be done like this. For simplicity, I demonstrate using a least squares ob...

15 days ago | 0

| accepted

Answered

optimoptions ga error - "Invalid solver specified"

That might happen if you have attempted this on a new Matlab installation which doesn't have the Global Optimization Toolbox ins...

optimoptions ga error - "Invalid solver specified"

That might happen if you have attempted this on a new Matlab installation which doesn't have the Global Optimization Toolbox ins...

15 days ago | 0

| accepted

Answered

Split an image into two sets

N=numel(yourImage); indices=randperm(N,round(N/2)); A=yourImage(indices); B=yourImage; B(indices)=[];

Split an image into two sets

N=numel(yourImage); indices=randperm(N,round(N/2)); A=yourImage(indices); B=yourImage; B(indices)=[];

16 days ago | 2

Answered

FMINUNC cannot continue help?

You forgot to pass your params, fobj = @(beta)myobj(beta,params); function [err, T, Y] = myobj(beta,params) ...

FMINUNC cannot continue help?

You forgot to pass your params, fobj = @(beta)myobj(beta,params); function [err, T, Y] = myobj(beta,params) ...

18 days ago | 0

| accepted

Answered

Diagonal matrices with spdiags

s=0.12; N_r=30; r=linspace(0,1,N_r)'; dr=r(2); r_plus=r+0.5*dr; r_minus=r-0.5*dr; a_plus=s*r_plus(1:end-1).^2; a_minus=s*...

Diagonal matrices with spdiags

s=0.12; N_r=30; r=linspace(0,1,N_r)'; dr=r(2); r_plus=r+0.5*dr; r_minus=r-0.5*dr; a_plus=s*r_plus(1:end-1).^2; a_minus=s*...

18 days ago | 0

| accepted

Answered

Approximation coefficients differencies when function fit and Fitting Curve are used

What is "Fitting Curve"? Do you mean the Curve Fitting app? Why do you think the fit function uses different starting points tha...

Approximation coefficients differencies when function fit and Fitting Curve are used

What is "Fitting Curve"? Do you mean the Curve Fitting app? Why do you think the fit function uses different starting points tha...

18 days ago | 0

Answered

How to convert or extract arrays from a structure?

S.coefs already is an array. If you mean that you want it in a separate non-struct variable, simply assign it to something, coe...

How to convert or extract arrays from a structure?

S.coefs already is an array. If you mean that you want it in a separate non-struct variable, simply assign it to something, coe...

18 days ago | 0

| accepted

Answered

Any way to use British spellings for function calls and arguments?

You can certainly write your own function aliases, as for example, function varargout=rgb2grey(varargin) [varargout{1:narg...

Any way to use British spellings for function calls and arguments?

You can certainly write your own function aliases, as for example, function varargout=rgb2grey(varargin) [varargout{1:narg...

18 days ago | 1

Answered

Error: Subscripting a table using linear indexing (one subscript) or multidimensional indexing (three or more subscripts) is not supported

Convert your y1 and y2 to arrays before doing anything else: function s=semblance(t,y1,y2,nscales) if istable(y1), y1=tab...

Error: Subscripting a table using linear indexing (one subscript) or multidimensional indexing (three or more subscripts) is not supported

Convert your y1 and y2 to arrays before doing anything else: function s=semblance(t,y1,y2,nscales) if istable(y1), y1=tab...

19 days ago | 1

| accepted

Answered

how can I do parallel computation on GPU?

That is not the way to take advantage of the GPU. Instead of trying to parallelize loop iterations, you get the benefit of the G...

how can I do parallel computation on GPU?

That is not the way to take advantage of the GPU. Instead of trying to parallelize loop iterations, you get the benefit of the G...

19 days ago | 1

| accepted

Answered

Building Sparse Matrix with Integer Errors

My eps are all real positive integers and my Phi_1 values are positive values to the smallest is 3*10^(-4). Does this not count?...

Building Sparse Matrix with Integer Errors

My eps are all real positive integers and my Phi_1 values are positive values to the smallest is 3*10^(-4). Does this not count?...

19 days ago | 1

| accepted

Answered

Solving large linear system of Ax=b while A is a non-square Matrix?

In addition to mldivide, as suggested by Walter, you could pre-multiply your equation by A.' to obtain the square symmetric syst...

Solving large linear system of Ax=b while A is a non-square Matrix?

In addition to mldivide, as suggested by Walter, you could pre-multiply your equation by A.' to obtain the square symmetric syst...

20 days ago | 0

| accepted

Answered

Edge linking and hole filling in binarized cell image

Use imclose with a disk structuring element se=strel('disk',n); ~imclose(~yourImage,se);

Edge linking and hole filling in binarized cell image

Use imclose with a disk structuring element se=strel('disk',n); ~imclose(~yourImage,se);

20 days ago | 0

Answered

fminunc stopped because it cannot decrease the objective function

The log of a sigmoid is a numerically delicate operation. You need to write your objective function with a dedicated log-sigmoid...

fminunc stopped because it cannot decrease the objective function

The log of a sigmoid is a numerically delicate operation. You need to write your objective function with a dedicated log-sigmoid...

20 days ago | 0

Answered

how to define a function inside a script so that I wont need to redefine local variables/tables to the function?

See Nested Functions.

how to define a function inside a script so that I wont need to redefine local variables/tables to the function?

See Nested Functions.

21 days ago | 0

Answered

finding all possible polynomial combinations of n variables

This should be better: n=30; combs=nchoosek(1:n,2); m=size(combs,1); S=sparse([1:m;1:m],combs.',1,m,n); exp_comb = [S;s...

finding all possible polynomial combinations of n variables

This should be better: n=30; combs=nchoosek(1:n,2); m=size(combs,1); S=sparse([1:m;1:m],combs.',1,m,n); exp_comb = [S;s...

21 days ago | 1

| accepted

Answered

finding all possible polynomial combinations of n variables

[vars{1:n}] = ndgrid(0:2); exp_comb = reshape(cat(n+1,vars{:}) ,[],n); exp_comb = exp_comb(sum(exp_comb,2)<=2 & sum(exp_c...

finding all possible polynomial combinations of n variables

[vars{1:n}] = ndgrid(0:2); exp_comb = reshape(cat(n+1,vars{:}) ,[],n); exp_comb = exp_comb(sum(exp_comb,2)<=2 & sum(exp_c...

21 days ago | 1

Answered

Coordinates of corners of quadrilateral in binary mask

The Computer Vision Toolbox has some ready-made corner detection functions, e.g., https://www.mathworks.com/help/vision/ref/det...

Coordinates of corners of quadrilateral in binary mask

The Computer Vision Toolbox has some ready-made corner detection functions, e.g., https://www.mathworks.com/help/vision/ref/det...

21 days ago | 0

| accepted

Answered

Remove coordiantes with less than n repeats in y coordinate

G=findgroups(y); [C,~,idx]=histcounts(y, 1:max(G)+1); keep=C(idx)>=n; coords=coords(keep,:)

Remove coordiantes with less than n repeats in y coordinate

G=findgroups(y); [C,~,idx]=histcounts(y, 1:max(G)+1); keep=C(idx)>=n; coords=coords(keep,:)

21 days ago | 0

| accepted

Answered

Implement average filter without using built-in functions

In all likelihood, you have not converted your image to floating point img = im2double( imread("Q3_Input", "tif") );

Implement average filter without using built-in functions

In all likelihood, you have not converted your image to floating point img = im2double( imread("Q3_Input", "tif") );

22 days ago | 1

| accepted

Answered

Linear Programming: Can you input fixed values to the output matrix ('x') before solving linprog for 'x'?

You can enforce this using upper and lower bounds ub(i)=lb(i)=knownvalue

Linear Programming: Can you input fixed values to the output matrix ('x') before solving linprog for 'x'?

You can enforce this using upper and lower bounds ub(i)=lb(i)=knownvalue

22 days ago | 1

| accepted

Answered

Sum of matrix times scalars

Hold your 3x3 matrices in a 3x3xN array caled T and your scalars in an Nx1 vector called a and do, result=reshape(T,9,[])*a(:);...

Sum of matrix times scalars

Hold your 3x3 matrices in a 3x3xN array caled T and your scalars in an Nx1 vector called a and do, result=reshape(T,9,[])*a(:);...

22 days ago | 1

| accepted

Answered

Please help me to using genetic algorithm

You can use prob2struct to obtain most of your problem parameters in solver form, problem=prob2struct(costprob); problem=rmf...

Please help me to using genetic algorithm

You can use prob2struct to obtain most of your problem parameters in solver form, problem=prob2struct(costprob); problem=rmf...

22 days ago | 1

| accepted

Answered

How to Convert Euler Angles (Z-X-Z Convention) to Axis Angles for Image Stack Rotation

If angle2 is a rotation in y, I think you really meant rot2 = imrotate3(rot1,-angle2,[0 1 0],'crop'); % rot about y

How to Convert Euler Angles (Z-X-Z Convention) to Axis Angles for Image Stack Rotation

If angle2 is a rotation in y, I think you really meant rot2 = imrotate3(rot1,-angle2,[0 1 0],'crop'); % rot about y

22 days ago | 0