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

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

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

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

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

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

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

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

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

16 days ago | 1

Answered

How can I change the 'MaxIterations' option in matlab 'createOptimProblem('fmincon',..........)'

You need to do this, opts=optimoptions('fmincon', 'MaxFunctionEvaluations',3000); problem = createOptimProblem('fmincon','x0...

How can I change the 'MaxIterations' option in matlab 'createOptimProblem('fmincon',..........)'

You need to do this, opts=optimoptions('fmincon', 'MaxFunctionEvaluations',3000); problem = createOptimProblem('fmincon','x0...

17 days ago | 1

| accepted

Answered

Inconsistency in the definition of two geometric transformation matrices (tform)

The second form is the one expected by maketform. The only difference between the two conventions is that with the first, the tr...

Inconsistency in the definition of two geometric transformation matrices (tform)

The second form is the one expected by maketform. The only difference between the two conventions is that with the first, the tr...

17 days ago | 0

| accepted

Submitted

Find vertices in image of convex polygon

Estimates the corner points of a pixelated convex polygon having a known number of vertices.

17 days ago | 9 downloads |

Answered

How can I find the coordinates of the top and bottom end plate and calculate the height?

The FEX submission pgonCorners (Download) can be used to find approximate corners for each of the vertebrae. Once you have the c...

How can I find the coordinates of the top and bottom end plate and calculate the height?

The FEX submission pgonCorners (Download) can be used to find approximate corners for each of the vertebrae. Once you have the c...

17 days ago | 0

| accepted

Answered

How to get the maximum value of an implicit function?

I believe this method does not allow me to change the number of points in X, It does, e.g., f = fimplicit(fun,[0,40,0,9],'Mesh...

How to get the maximum value of an implicit function?

I believe this method does not allow me to change the number of points in X, It does, e.g., f = fimplicit(fun,[0,40,0,9],'Mesh...

18 days ago | 0

Answered

How to avoid looping of anonymous function?

You could make it the end-user's responsibility to enter the function in anonymous form, >> f=input('Enter anonymous function: ...

How to avoid looping of anonymous function?

You could make it the end-user's responsibility to enter the function in anonymous form, >> f=input('Enter anonymous function: ...

18 days ago | 0

Answered

Fit image datapoints to curve

You would use a 2D version of an Iterative Closest Point (ICP) algorithm. This FEX contribution appears to have one: https://ww...

Fit image datapoints to curve

You would use a 2D version of an Iterative Closest Point (ICP) algorithm. This FEX contribution appears to have one: https://ww...

19 days ago | 0

Answered

Write a script that calculates the user produced polynomial. The polynomial can be input until the user decides to terminate the program.

If you have the Symbolic Math Toolbox and wish to manipulate the polynomials in symbolic form, you can use poly2sym, >> p = inp...

Write a script that calculates the user produced polynomial. The polynomial can be input until the user decides to terminate the program.

If you have the Symbolic Math Toolbox and wish to manipulate the polynomials in symbolic form, you can use poly2sym, >> p = inp...

24 days ago | 1

| accepted

Answered

sparse and gpuArray/sparse errors very odd! (with MWE)

Ultimately, the reason is that you are creating matrices that violate various internal array size restrictions. There are differ...

sparse and gpuArray/sparse errors very odd! (with MWE)

Ultimately, the reason is that you are creating matrices that violate various internal array size restrictions. There are differ...

24 days ago | 1

Answered

"Index exceeds the number of array elements"

Perhaps this is what you are looking for, function [Ex, Ey, Ez] = E_field(x,y,z) R_s = 0.02; V = 0; epnaut = 8...

"Index exceeds the number of array elements"

Perhaps this is what you are looking for, function [Ex, Ey, Ez] = E_field(x,y,z) R_s = 0.02; V = 0; epnaut = 8...

25 days ago | 0

| accepted

Answered

how to do violin plot in matlab

Here's my personal favorite. https://github.com/bastibe/Violinplot-Matlab

how to do violin plot in matlab

Here's my personal favorite. https://github.com/bastibe/Violinplot-Matlab

25 days ago | 0

| accepted

Answered

Can't figure out what I am doing wrong. Looking to find square root using the equation given x=(x+x/a)/2. I also feel like I am not making use of the approximation errors ea and es.

You need to take absolute values, ea=abs((x-x_old)/x)*100;

Can't figure out what I am doing wrong. Looking to find square root using the equation given x=(x+x/a)/2. I also feel like I am not making use of the approximation errors ea and es.

You need to take absolute values, ea=abs((x-x_old)/x)*100;

25 days ago | 1

| accepted

Answered

Unable to convert expression into double array

One way is to convert the symbolic expression to a function with matlabFunction. Then you can pass values to it as for any funct...

Unable to convert expression into double array

One way is to convert the symbolic expression to a function with matlabFunction. Then you can pass values to it as for any funct...

26 days ago | 0

| accepted

Answered

Finding the matrix I generated two iterations back, while loop

One option is to maintain a list of the last two D's in a cell array: C = [0 0 0; 1 1 1;0 0 0]; B = [zeros(1, N); C; zeros(...

Finding the matrix I generated two iterations back, while loop

One option is to maintain a list of the last two D's in a cell array: C = [0 0 0; 1 1 1;0 0 0]; B = [zeros(1, N); C; zeros(...

26 days ago | 0

| accepted

Answered

Newton's Method in Matlab

Did you check whether the while loop is ever executed, even once? I don't think it is.

Newton's Method in Matlab

Did you check whether the while loop is ever executed, even once? I don't think it is.

26 days ago | 1

Answered

Constraining Function in fmincon

Now that the problem is clearer, it appears to me that you could have done the whole thing with linprog, f=[2,1]*t; Aineq = -...

Constraining Function in fmincon

Now that the problem is clearer, it appears to me that you could have done the whole thing with linprog, f=[2,1]*t; Aineq = -...

26 days ago | 0

Answered

Upsampled image FFT contains NaNs.

You have a division by zero in this line, res = y./scale; That leads to NaNs in cp_vol and hence also in shift_vol.

Upsampled image FFT contains NaNs.

You have a division by zero in this line, res = y./scale; That leads to NaNs in cp_vol and hence also in shift_vol.

26 days ago | 0

| accepted

Answered

Better parallelization than parfor?

The reason why I think it could be improved is that MATLAB tells me that vec in my above example is a 'broadcast' variable and m...

Better parallelization than parfor?

The reason why I think it could be improved is that MATLAB tells me that vec in my above example is a 'broadcast' variable and m...

26 days ago | 0

Answered

Nonlinear Least Squares implementation

[x,resnorm,res,eflag,output1] = lsqnonlin(@(x) myLS(F, S0, r, w, t, Q0, x) ,x0) See also Passing Extra Parameters.

Nonlinear Least Squares implementation

[x,resnorm,res,eflag,output1] = lsqnonlin(@(x) myLS(F, S0, r, w, t, Q0, x) ,x0) See also Passing Extra Parameters.

26 days ago | 1

| accepted

Answered

Returning an Entire Row Based on the Max in a Column

[~,imax]=max(x(:,2)); out = x(imax,:)

Returning an Entire Row Based on the Max in a Column

[~,imax]=max(x(:,2)); out = x(imax,:)

26 days ago | 0

| accepted

Answered

Constraining Function in fmincon

It sounds like you need to apply a nonlinear constraint. If so, you need to use fmincon with 9 or more input arguments specified...

Constraining Function in fmincon

It sounds like you need to apply a nonlinear constraint. If so, you need to use fmincon with 9 or more input arguments specified...

26 days ago | 0

| accepted