Answered

Weighted fit with lsqcurvefit and (ideally) multistart?

Just apply whatever weights you want to the objective and to your ydata, fun=@(x,xdata)kinetics_full(x,xdata).*sqrt(weights); ...

Weighted fit with lsqcurvefit and (ideally) multistart?

Just apply whatever weights you want to the objective and to your ydata, fun=@(x,xdata)kinetics_full(x,xdata).*sqrt(weights); ...

10 days ago | 0

Answered

Rotate matrix with interp2

This might be what you want. [X,Y]=meshgrid(x-mean(x),y-mean(y));

Rotate matrix with interp2

This might be what you want. [X,Y]=meshgrid(x-mean(x),y-mean(y));

10 days ago | 0

| accepted

Answered

Finding angle of rotations from a given unit vector to rotate a given vector using those angle to align with the previous unit vector

The following might be what you're looking for. It uses my AxelRot utility from the File Exchange https://www.mathworks.com/mat...

Finding angle of rotations from a given unit vector to rotate a given vector using those angle to align with the previous unit vector

The following might be what you're looking for. It uses my AxelRot utility from the File Exchange https://www.mathworks.com/mat...

11 days ago | 0

| accepted

Answered

Nested For Loop for 2D Matrix

I vaguely wonder whether you are just re-inventing convolution result = conv2(Matrix,staticMatrix,'valid');

Nested For Loop for 2D Matrix

I vaguely wonder whether you are just re-inventing convolution result = conv2(Matrix,staticMatrix,'valid');

11 days ago | 0

Answered

Nested For Loop for 2D Matrix

So then you want to extract random 51x51 submatrices? If so, then, I=sort(randperm(600,51)); J=sort(randperm(1000,51)); sub...

Nested For Loop for 2D Matrix

So then you want to extract random 51x51 submatrices? If so, then, I=sort(randperm(600,51)); J=sort(randperm(1000,51)); sub...

11 days ago | 0

| accepted

Answered

The result of rotation matrix rotx(angle) with a coordinate does not give the desired result

Here's what my AxelRot utility gives https://www.mathworks.com/matlabcentral/fileexchange/30864-3d-rotation-about-shifted-axis?...

The result of rotation matrix rotx(angle) with a coordinate does not give the desired result

Here's what my AxelRot utility gives https://www.mathworks.com/matlabcentral/fileexchange/30864-3d-rotation-about-shifted-axis?...

11 days ago | 0

Answered

how can I find the coordinates of the central axis of a river in an image (binary)?

load River C=watershed(bwdist(A))==0; [icoords,jcoords]=find(C); %coordinates of center line imshow(A+C)

how can I find the coordinates of the central axis of a river in an image (binary)?

load River C=watershed(bwdist(A))==0; [icoords,jcoords]=find(C); %coordinates of center line imshow(A+C)

11 days ago | 2

| accepted

Answered

Count the number of intersections between any two curves

The only general way (i.e., for arbitrary curves) is using the Symbolic Math Toolbox, solve(curve1==curve2)

Count the number of intersections between any two curves

The only general way (i.e., for arbitrary curves) is using the Symbolic Math Toolbox, solve(curve1==curve2)

11 days ago | 1

Answered

How to match a number between two characters?

>> str=extractBetween("[180] Windabweichung","[","]") str = "180"

How to match a number between two characters?

>> str=extractBetween("[180] Windabweichung","[","]") str = "180"

11 days ago | 0

| accepted

Answered

How to match a number between two characters?

>> T=regexp('[180] Windabweichung','\[(\d+)\]','tokens'); T{:} ans = 1×1 cell array {'180'}

How to match a number between two characters?

>> T=regexp('[180] Windabweichung','\[(\d+)\]','tokens'); T{:} ans = 1×1 cell array {'180'}

11 days ago | 0

Answered

Images as the Options in a Drop Down Menu

See here, https://undocumentedmatlab.com/blog/icon-images-in-matlab-uicontrols

Images as the Options in a Drop Down Menu

See here, https://undocumentedmatlab.com/blog/icon-images-in-matlab-uicontrols

12 days ago | 1

Answered

License Manager error -96 (of matlab 2018b)

This may help https://www.mathworks.com/matlabcentral/answers/95122-why-do-i-receive-license-manager-error-96?s_tid=answers_rc1...

License Manager error -96 (of matlab 2018b)

This may help https://www.mathworks.com/matlabcentral/answers/95122-why-do-i-receive-license-manager-error-96?s_tid=answers_rc1...

14 days ago | 0

Answered

how can i find the stationary points of this equation and find its nature in the region x>0.

You can use diff to get numerical approximations of the derivatives and apply stationary point criteria based on those. If need...

how can i find the stationary points of this equation and find its nature in the region x>0.

You can use diff to get numerical approximations of the derivatives and apply stationary point criteria based on those. If need...

14 days ago | 0

Answered

The best way to write a large number of constraints for an optimization problem

If they are linear constraints, they will be expressed using matrix-vector multiplication A*x<=b Aeq*x<=beq so any vectorized...

The best way to write a large number of constraints for an optimization problem

If they are linear constraints, they will be expressed using matrix-vector multiplication A*x<=b Aeq*x<=beq so any vectorized...

16 days ago | 0

| accepted

Answered

How do I remove NaN values from a cell array?

The presence of NaNs isn't the problem. The problem is that the cell contents are character vectors of different lengths. You ca...

How do I remove NaN values from a cell array?

The presence of NaNs isn't the problem. The problem is that the cell contents are character vectors of different lengths. You ca...

16 days ago | 0

| accepted

Answered

Fmincon linear contraint doens't work in my case

You should check the EXITFLAG output to see if fmincon believes it converged. If it did converge, the ranges should be satisfied...

Fmincon linear contraint doens't work in my case

You should check the EXITFLAG output to see if fmincon believes it converged. If it did converge, the ranges should be satisfied...

17 days ago | 0

| accepted

Answered

How can i create a convolution using toeplitz matrix?

Consider >> x=1:5, y=rand(1,5), x = 1 2 3 4 5 y = 0.2899 0.4714 0.8782 0.6555 ...

How can i create a convolution using toeplitz matrix?

Consider >> x=1:5, y=rand(1,5), x = 1 2 3 4 5 y = 0.2899 0.4714 0.8782 0.6555 ...

17 days ago | 0

| accepted

Answered

fminunc: get Hessian approximation after each iteration

You could try running fminunc 1 iteration at a time in a for-loop and saving the 6th output arguments, options.MaxIter=1; ...

fminunc: get Hessian approximation after each iteration

You could try running fminunc 1 iteration at a time in a for-loop and saving the 6th output arguments, options.MaxIter=1; ...

17 days ago | 0

| accepted

Answered

Using FFT in for-loop is extremely slow - how to accelerate?

To conserve memory, I only store the results for x,y,z inside the mask. It would be straightforward to re-embed them in 4D array...

Using FFT in for-loop is extremely slow - how to accelerate?

To conserve memory, I only store the results for x,y,z inside the mask. It would be straightforward to re-embed them in 4D array...

17 days ago | 0

| accepted

Answered

Can someone propose some code that will "connect the dots" to produce the correct geometric shapes (i.e., hexagons, pentagons, rectangles) from these points?

Here is a refinement of my earlier answer which I think performs better. It uses the attached classdef file to create objects re...

Can someone propose some code that will "connect the dots" to produce the correct geometric shapes (i.e., hexagons, pentagons, rectangles) from these points?

Here is a refinement of my earlier answer which I think performs better. It uses the attached classdef file to create objects re...

18 days ago | 1

Answered

Create matrix (30 x 12) with numbers from 1 to 12 without repetition without any repetitions of following numbers for each row

Note that there are only >> nchoosek(12,2)*2 ans = 132 distinct subsequences of length 2 that can be drawn from the numbe...

Create matrix (30 x 12) with numbers from 1 to 12 without repetition without any repetitions of following numbers for each row

Note that there are only >> nchoosek(12,2)*2 ans = 132 distinct subsequences of length 2 that can be drawn from the numbe...

18 days ago | 0

Answered

Can someone propose some code that will "connect the dots" to produce the correct geometric shapes (i.e., hexagons, pentagons, rectangles) from these points?

This seems to do it. For the display part, it uses plotpts2d, which you've seen before. maxDistLine=10; %User tolerance s...

Can someone propose some code that will "connect the dots" to produce the correct geometric shapes (i.e., hexagons, pentagons, rectangles) from these points?

This seems to do it. For the display part, it uses plotpts2d, which you've seen before. maxDistLine=10; %User tolerance s...

21 days ago | 0

| accepted

Answered

Data: Interp1 spline and cubic method

how would you approximate this data using the Interp1 function and spline method For example, year=[1;2;3;4;5;6;7;8;9;10]; po...

Data: Interp1 spline and cubic method

how would you approximate this data using the Interp1 function and spline method For example, year=[1;2;3;4;5;6;7;8;9;10]; po...

21 days ago | 1

| accepted

Answered

Can I set restrictions on the output matrix from "linprog" before solving?

If X is constrained to be binary (using intlinprog rather than linprog), then this condition is equivalent to the linear inequal...

Can I set restrictions on the output matrix from "linprog" before solving?

If X is constrained to be binary (using intlinprog rather than linprog), then this condition is equivalent to the linear inequal...

22 days ago | 0

Answered

Derivative constraint in curve fitting

You can do spline fits with those kinds of constraints using this, https://www.mathworks.com/matlabcentral/fileexchange/24443-s...

Derivative constraint in curve fitting

You can do spline fits with those kinds of constraints using this, https://www.mathworks.com/matlabcentral/fileexchange/24443-s...

22 days ago | 1

Answered

Why parfor could read the deleted script?

Remember that in a parfor loop, you are responsible for ensuring that no operations in the loop that depend on the order of exec...

Why parfor could read the deleted script?

Remember that in a parfor loop, you are responsible for ensuring that no operations in the loop that depend on the order of exec...

23 days ago | 0

| accepted

Answered

Converting 3D matrix to a bigger 2D matrix efficiently

[ma,na,~]=size(A); B=permute(reshape(A,ma,na,2,2), [4,1,3,2]); B=reshape(B,2*ma,2*na)

Converting 3D matrix to a bigger 2D matrix efficiently

[ma,na,~]=size(A); B=permute(reshape(A,ma,na,2,2), [4,1,3,2]); B=reshape(B,2*ma,2*na)

23 days ago | 1

| accepted

Answered

Converting 3D matrix to a bigger 2D matrix efficiently

Is there an efficient way to create the B matrix without using loops? There is nothing inefficient about using loops in this ca...

Converting 3D matrix to a bigger 2D matrix efficiently

Is there an efficient way to create the B matrix without using loops? There is nothing inefficient about using loops in this ca...

23 days ago | 2

Answered

How to check the internal solution results of Fsolve to know where the matrix dimension assignment has problem?

Yes, if you re-run your code after executing >> dbstop if caught error at the command line, the code will pause execution at t...

How to check the internal solution results of Fsolve to know where the matrix dimension assignment has problem?

Yes, if you re-run your code after executing >> dbstop if caught error at the command line, the code will pause execution at t...

23 days ago | 1

| accepted

Answered

Unable to perform assignment because brace indexing is not supported for variables of this type.

grade = cell(1,length(fish)); price = cell(1,length(fish)); use = cell(1,length(fish)); % preallocate cell array. Also, these...

Unable to perform assignment because brace indexing is not supported for variables of this type.

grade = cell(1,length(fish)); price = cell(1,length(fish)); use = cell(1,length(fish)); % preallocate cell array. Also, these...

24 days ago | 0