Answered

Question about for loop problem

I don't see any mistakes (that's why posting your error messages and output is always a good thing), however, the whole thing ca...

Question about for loop problem

I don't see any mistakes (that's why posting your error messages and output is always a good thing), however, the whole thing ca...

8 Tage ago | 0

Answered

How to find the indices that a point lays between?

Do you suggest another way? In case X is not increasing. If X,Y are non-monotonic, I would do [~,points] = pdist2([X(:),Y(:)],...

How to find the indices that a point lays between?

Do you suggest another way? In case X is not increasing. If X,Y are non-monotonic, I would do [~,points] = pdist2([X(:),Y(:)],...

8 Tage ago | 1

Answered

How to find the indices that a point lays between?

find is inefficient. You should instead do, point1=discretize(xA,X); point2=point1+1;

How to find the indices that a point lays between?

find is inefficient. You should instead do, point1=discretize(xA,X); point2=point1+1;

8 Tage ago | 0

Answered

Split array into multiple columns based on another array

result = splitapply(@(x) {x}, DHB_combine,index_combine);

Split array into multiple columns based on another array

result = splitapply(@(x) {x}, DHB_combine,index_combine);

8 Tage ago | 0

Answered

how to plot a fitness or objective function with optimum values

Sounds like you want this? options = optimoptions('ga','PlotFcn',{'gaplotbestf','gaplotbestindiv'}); [x,fval] = ga(Objective...

how to plot a fitness or objective function with optimum values

Sounds like you want this? options = optimoptions('ga','PlotFcn',{'gaplotbestf','gaplotbestindiv'}); [x,fval] = ga(Objective...

8 Tage ago | 0

Answered

Multi-objective optimisation using results from external simulation

MATLAB optimization solvers require that you provide a function which take a guess of your unknowns as input and return the quan...

Multi-objective optimisation using results from external simulation

MATLAB optimization solvers require that you provide a function which take a guess of your unknowns as input and return the quan...

8 Tage ago | 1

Answered

Subset multidimensional array using a vector

idx=repmat({':'},1,ndims(A)); idx(1:numel(v))=num2cell(v); result=A(idx{:});

Subset multidimensional array using a vector

idx=repmat({':'},1,ndims(A)); idx(1:numel(v))=num2cell(v); result=A(idx{:});

8 Tage ago | 1

Answered

Sorting and averaging matrices

[~,idx]=sort( reshape(A,8,[]) ,1); [m,n]=size(idx); C=reshape(B,m,n,[]); [m,n,p]=size(C); idx=i...

Sorting and averaging matrices

[~,idx]=sort( reshape(A,8,[]) ,1); [m,n]=size(idx); C=reshape(B,m,n,[]); [m,n,p]=size(C); idx=i...

8 Tage ago | 2

| accepted

Answered

fmincon command to find minimum value of Rosenbrock's function in Polygonal domain

You have miscalculated your A and b. You can use vert2lcon to obtain them automatically, https://www.mathworks.com/matlabcentra...

fmincon command to find minimum value of Rosenbrock's function in Polygonal domain

You have miscalculated your A and b. You can use vert2lcon to obtain them automatically, https://www.mathworks.com/matlabcentra...

9 Tage ago | 0

| accepted

Answered

Action shot function with multiple images

Yes, here is an approach that uses no loops, Image4D=double(cat(4,ImageCell{:})); MedianImage = median(Image4D,4); [~,idx...

Action shot function with multiple images

Yes, here is an approach that uses no loops, Image4D=double(cat(4,ImageCell{:})); MedianImage = median(Image4D,4); [~,idx...

10 Tage ago | 3

| accepted

Answered

Undefined function for input arguments of type 'double': how do I make them vectors and not doubles?

Here is the non-symbolic approach mentioned by Adam. function[val,g,H]=givenfGNM(x) %givenf() modified to output the Hessian a...

Undefined function for input arguments of type 'double': how do I make them vectors and not doubles?

Here is the non-symbolic approach mentioned by Adam. function[val,g,H]=givenfGNM(x) %givenf() modified to output the Hessian a...

10 Tage ago | 1

Answered

Removing object from image using median filter

I'll call your 1xn cell array of images ImageCell. Then I think you want, Image4D=cat(4,ImageCell{:}); R=median( Image4D(:,:...

Removing object from image using median filter

I'll call your 1xn cell array of images ImageCell. Then I think you want, Image4D=cat(4,ImageCell{:}); R=median( Image4D(:,:...

10 Tage ago | 2

| accepted

Answered

Avoiding local minimum with fmincon

So my question is: Is there any way to avoid local minimum using fmincon or fminunc? There is no systematic, problem-independen...

Avoiding local minimum with fmincon

So my question is: Is there any way to avoid local minimum using fmincon or fminunc? There is no systematic, problem-independen...

10 Tage ago | 2

Answered

Could anyone help me how to solve the issue.

[m,n]=size(a); differences=reshape(a,m,1,n) - reshape(a,1,m,n);

Could anyone help me how to solve the issue.

[m,n]=size(a); differences=reshape(a,m,1,n) - reshape(a,1,m,n);

12 Tage ago | 1

| accepted

Answered

which way to call function is better?

I have more than hundred of input parameters in myfunc and I am using the following way to call the function after grouping the ...

which way to call function is better?

I have more than hundred of input parameters in myfunc and I am using the following way to call the function after grouping the ...

12 Tage ago | 0

Answered

fmincon gradient of nonlinear inequality constraints must have size???

What is mysterious about the error message? It has told you that your gradc output has to be 4x12 and in your NLC2 you clearly o...

fmincon gradient of nonlinear inequality constraints must have size???

What is mysterious about the error message? It has told you that your gradc output has to be 4x12 and in your NLC2 you clearly o...

12 Tage ago | 0

Answered

What is the best way to store groups of 3 nearest non-zero pixels?

I would like to identify and store each set of 3 closest points (as seen in the attached image) in a separate variable. No, you...

What is the best way to store groups of 3 nearest non-zero pixels?

I would like to identify and store each set of 3 closest points (as seen in the attached image) in a separate variable. No, you...

12 Tage ago | 0

| accepted

Answered

matrix multiplication for "3-D" matrices

result=nan(2,2,100); result(1,1,:)=a11.*b11 + a12.*b21; result(1,2,:)=a11.*b12 + a12.*b22; result(2,1,:)=a21.*b11 + a22.*b2...

matrix multiplication for "3-D" matrices

result=nan(2,2,100); result(1,1,:)=a11.*b11 + a12.*b21; result(1,2,:)=a11.*b12 + a12.*b22; result(2,1,:)=a21.*b11 + a22.*b2...

12 Tage ago | 0

| accepted

Answered

More than 580 billion possibilities

Sure, for example, count=0; for i=1:580*1e9 possibility=rand; if possibility>0.5 count=count+1...

More than 580 billion possibilities

Sure, for example, count=0; for i=1:580*1e9 possibility=rand; if possibility>0.5 count=count+1...

12 Tage ago | 0

| accepted

Answered

GPU optimization of looped vector operations

This modification uses mat2tiles from the File Exchange, to help divide the computation into bigger, vectorized chunks https://...

GPU optimization of looped vector operations

This modification uses mat2tiles from the File Exchange, to help divide the computation into bigger, vectorized chunks https://...

13 Tage ago | 1

| accepted

Answered

Programatically creating an anonymous function that separates "Variables" and "Parameters"

I just wanted to mention that a generic simplifier like what you have asked for will not normally give you the best performance....

Programatically creating an anonymous function that separates "Variables" and "Parameters"

I just wanted to mention that a generic simplifier like what you have asked for will not normally give you the best performance....

13 Tage ago | 0

Answered

How can i fit the data to the custom equation without using Curve fitting Toolbox ?

FMINSPLEAS will work well for this problem. It uses fminsearch, but in a savvy way that reduces the problem to only 2 unknowns. ...

How can i fit the data to the custom equation without using Curve fitting Toolbox ?

FMINSPLEAS will work well for this problem. It uses fminsearch, but in a savvy way that reduces the problem to only 2 unknowns. ...

13 Tage ago | 1

| accepted

Answered

FMINCON: Interior-Point algo -> Is there a way to pass extra parameters to the hessian function or allow the objective function to return 3 output variables (function value, gradient and hessian) when there are no nonlinear constraints?

Also, even if my hessian could be computed solely using 'x', this approach would not be ideal - computing the hessian requires c...

FMINCON: Interior-Point algo -> Is there a way to pass extra parameters to the hessian function or allow the objective function to return 3 output variables (function value, gradient and hessian) when there are no nonlinear constraints?

Also, even if my hessian could be computed solely using 'x', this approach would not be ideal - computing the hessian requires c...

13 Tage ago | 0

| accepted

Answered

I'm trying to crop a circle from an image using imfindcircle... but It deosn't work. what is the issue ?

Swap the coordinates in the output of imfindcircles. [xx,yy] = ndgrid((1:imagesize(1))-centers(2),(1:imagesize(2))-centers(1));...

I'm trying to crop a circle from an image using imfindcircle... but It deosn't work. what is the issue ?

Swap the coordinates in the output of imfindcircles. [xx,yy] = ndgrid((1:imagesize(1))-centers(2),(1:imagesize(2))-centers(1));...

13 Tage ago | 0

| accepted

Answered

Matlab Curve Fitting Algorithm

If you didn't specify any lower/upper bounds in the fitoptions, then the 'poly11' fitting task has the form of an unconstrained ...

Matlab Curve Fitting Algorithm

If you didn't specify any lower/upper bounds in the fitoptions, then the 'poly11' fitting task has the form of an unconstrained ...

14 Tage ago | 1

| accepted

Answered

Weighted linear combination between vectors

weights=[1 2 3 4]; C=W*weights(:);

Weighted linear combination between vectors

weights=[1 2 3 4]; C=W*weights(:);

15 Tage ago | 1

| accepted

Answered

how to define binary decision variable in multi objective optimization (gamultiobj) problem

There must be a reason why integer constraints are not supported, but you could try to enforce binariness through non-linear equ...

how to define binary decision variable in multi objective optimization (gamultiobj) problem

There must be a reason why integer constraints are not supported, but you could try to enforce binariness through non-linear equ...

15 Tage ago | 0

Answered

Erro in calling function in fsolve that has conditional operators

Change these two lines, %F1=ferror(x2d,x2n) Error=fsolve(@(x2) ferror(x2d,x2n,x2),0) Also, make sure to pass all variables th...

Erro in calling function in fsolve that has conditional operators

Change these two lines, %F1=ferror(x2d,x2n) Error=fsolve(@(x2) ferror(x2d,x2n,x2),0) Also, make sure to pass all variables th...

15 Tage ago | 0

| accepted

Answered

How do I plot an equation with an imaginary quantity?

If you mean that you want the values plotted in the complex plane, then t=[0:0.01:10]; y=exp(-5*i*t); scatter(real(y),imag(y)...

How do I plot an equation with an imaginary quantity?

If you mean that you want the values plotted in the complex plane, then t=[0:0.01:10]; y=exp(-5*i*t); scatter(real(y),imag(y)...

15 Tage ago | 0

Answered

How to use persistent variables inside parfor method of a custom object class?

Here's one way to do it, sort of along the lines that Walter proposed, but with externally scoped variables instead of persisten...

How to use persistent variables inside parfor method of a custom object class?

Here's one way to do it, sort of along the lines that Walter proposed, but with externally scoped variables instead of persisten...

15 Tage ago | 1