Answered

How to obtain all permutations of multiple cell arrays?

This is better because the for loop is only 6 iterations long. A={'a1'; 'a2'; 'a3'}; B={'b1'; 'b2'}; C={'c1'; 'c2'; 'c3'; 'c4...

How to obtain all permutations of multiple cell arrays?

This is better because the for loop is only 6 iterations long. A={'a1'; 'a2'; 'a3'}; B={'b1'; 'b2'}; C={'c1'; 'c2'; 'c3'; 'c4...

1 month ago | 0

| accepted

Answered

Vectors must be the same length

i = gradient(q(:, 1),t); % Current derivative U_R = R * i; % Resistor's voltage U_L = L * gradient(i,t); ...

Vectors must be the same length

i = gradient(q(:, 1),t); % Current derivative U_R = R * i; % Resistor's voltage U_L = L * gradient(i,t); ...

1 month ago | 1

| accepted

Answered

affine3d used for pure rotation causes translational misalignment

I don't really understand how your posted images show that something is wrong. It shows that the image has changed after the war...

affine3d used for pure rotation causes translational misalignment

I don't really understand how your posted images show that something is wrong. It shows that the image has changed after the war...

1 month ago | 0

| accepted

Answered

Non linear fit extremely bad : what am I doing wrong ?

There are ways to derive an accurate x0 more systematically, e.g., rng('default') t = 0:0.02:10; x = t.*sin(2*pi*1*t) + 0.1*ra...

Non linear fit extremely bad : what am I doing wrong ?

There are ways to derive an accurate x0 more systematically, e.g., rng('default') t = 0:0.02:10; x = t.*sin(2*pi*1*t) + 0.1*ra...

1 month ago | 0

| accepted

Answered

How to avoid counting elements in each row of matrix multiple times?

Xedges=linspace(Xmin,Xmax, Nbin+1); Yedges=linspace(Ymin,Ymax, Nbin+1); N=0; for i=1:height(X) deltaN = histcounts...

How to avoid counting elements in each row of matrix multiple times?

Xedges=linspace(Xmin,Xmax, Nbin+1); Yedges=linspace(Ymin,Ymax, Nbin+1); N=0; for i=1:height(X) deltaN = histcounts...

1 month ago | 0

Answered

How to put different size vectors to one matrix or mat file?

To save to a .mat file save filename d1 d2 d3 d4 To retrieve them, packaged in a struct variable, S=load('filename'); To wri...

How to put different size vectors to one matrix or mat file?

To save to a .mat file save filename d1 d2 d3 d4 To retrieve them, packaged in a struct variable, S=load('filename'); To wri...

1 month ago | 1

| accepted

Answered

finding the value of a corresponding column in matrix

models = A(A(:,1)==40,2)

finding the value of a corresponding column in matrix

models = A(A(:,1)==40,2)

1 month ago | 0

| accepted

Answered

lsqcurvefit answer upon termination?

You can use a nested OutputFcn, like in this example, https://www.mathworks.com/help/matlab/math/output-functions.html#bsgpq6q-...

lsqcurvefit answer upon termination?

You can use a nested OutputFcn, like in this example, https://www.mathworks.com/help/matlab/math/output-functions.html#bsgpq6q-...

1 month ago | 0

| accepted

Answered

Newton Raphson gives answers divided by 0

Raw Newton-Raphson is a pretty terrible method, but I assume you'll tell us you have no choice... [f,M]=preanalysis(); %Symbo...

Newton Raphson gives answers divided by 0

Raw Newton-Raphson is a pretty terrible method, but I assume you'll tell us you have no choice... [f,M]=preanalysis(); %Symbo...

1 month ago | 0

Answered

Adding elements to matrix

A=[1 2 3 4 5 6 7 8 9 10] B=[reshape(A,2,[]); zeros(1,numel(A)/2)]; B=[0,B(:)'] %the result

Adding elements to matrix

A=[1 2 3 4 5 6 7 8 9 10] B=[reshape(A,2,[]); zeros(1,numel(A)/2)]; B=[0,B(:)'] %the result

1 month ago | 1

| accepted

Answered

What does MATLAB actually do when switching precisions?

I don't know Julia, but I don't believe the binary decomposition was done correctly. Below is the way to do the binary decomposi...

What does MATLAB actually do when switching precisions?

I don't know Julia, but I don't believe the binary decomposition was done correctly. Below is the way to do the binary decomposi...

1 month ago | 2

| accepted

Answered

lines that meet each other

You can use, https://www.mathworks.com/matlabcentral/fileexchange/93470-intersections-of-multiple-2d-lines-or-line-segments

lines that meet each other

You can use, https://www.mathworks.com/matlabcentral/fileexchange/93470-intersections-of-multiple-2d-lines-or-line-segments

1 month ago | 0

Answered

How to compute integrals on the GPU using trapz function

You cannot use trapz within gpuArray.arrayfun, but I don't think you really need it. On my computer, the following takes about 3...

How to compute integrals on the GPU using trapz function

You cannot use trapz within gpuArray.arrayfun, but I don't think you really need it. On my computer, the following takes about 3...

2 months ago | 0

| accepted

Answered

augmentedImageDatastore for image segmentation

Supply the training data in numeric form: X_training = rand([224 224 3 200]) ; %Fake Y_training = rand([224 224 1 200]) ; %Fak...

augmentedImageDatastore for image segmentation

Supply the training data in numeric form: X_training = rand([224 224 3 200]) ; %Fake Y_training = rand([224 224 1 200]) ; %Fak...

2 months ago | 1

| accepted

Answered

Interpolation to arbitrary points on a patch plot

For example, F=scatteredInterpolant(msh_1.xy, q); interpolatedValues = F({[0.68,1.87],0:0.2:1})

Interpolation to arbitrary points on a patch plot

For example, F=scatteredInterpolant(msh_1.xy, q); interpolatedValues = F({[0.68,1.87],0:0.2:1})

2 months ago | 0

Answered

When eigs uses a custom function as input, it cannot compute an eigenvalue near a specified sigma

n = 10; A = randn(n); A = A + A'; E1=eigs(A,5,'sa')'; sigma = E1(2)+1; E2=eigs(A,5,sigma)'; E3 = eigs(@(x) (A-s...

When eigs uses a custom function as input, it cannot compute an eigenvalue near a specified sigma

n = 10; A = randn(n); A = A + A'; E1=eigs(A,5,'sa')'; sigma = E1(2)+1; E2=eigs(A,5,sigma)'; E3 = eigs(@(x) (A-s...

2 months ago | 0

Answered

solving quadratic roots in matlab

Hint: You should consider applying the quadratic formula.

solving quadratic roots in matlab

Hint: You should consider applying the quadratic formula.

2 months ago | 0

Answered

how to create image data store? I do not have clarity regarding the arguments in ImageDataStore as studied from the website

Matlab does not understand (and neither do we) how a single "test1.tif" is supposed to specify labels for all of your images. Th...

how to create image data store? I do not have clarity regarding the arguments in ImageDataStore as studied from the website

Matlab does not understand (and neither do we) how a single "test1.tif" is supposed to specify labels for all of your images. Th...

2 months ago | 0

Answered

Running into issue using fsolve

There are no errors in what you've shown, but it is peculiar that you have one optimization (with fsolve) nested inside another ...

Running into issue using fsolve

There are no errors in what you've shown, but it is peculiar that you have one optimization (with fsolve) nested inside another ...

2 months ago | 0

| accepted

Answered

How to ask Matlab ga to continously regenerate individuals until they all satisfy user defined constraints prior to fitness evaluation

The way to handle that is to have the fitness function skip the FE modeling and return Inf (or some large penalizing value) if t...

How to ask Matlab ga to continously regenerate individuals until they all satisfy user defined constraints prior to fitness evaluation

The way to handle that is to have the fitness function skip the FE modeling and return Inf (or some large penalizing value) if t...

2 months ago | 0

| accepted

Answered

Efficiently handling extremely large matrices (N x N) in MATLAB (e.g., N = 137 million)

Could you provide examples of using sparse matrices You give us wide latitude on what the example can be be, so here is one: A...

Efficiently handling extremely large matrices (N x N) in MATLAB (e.g., N = 137 million)

Could you provide examples of using sparse matrices You give us wide latitude on what the example can be be, so here is one: A...

2 months ago | 0

Answered

Fast dataset manipulation in MATLAB

The implementation that you wrote first, R = [cos(theta) -sin(theta); sin(theta) cos(theta)]; bary = R' * (y - p); is alre...

Fast dataset manipulation in MATLAB

The implementation that you wrote first, R = [cos(theta) -sin(theta); sin(theta) cos(theta)]; bary = R' * (y - p); is alre...

2 months ago | 1

| accepted

Answered

Expanding a cell array in table into multiple rows

Here's a scaled-down example: T=table(1,2,3,{rand(4,3)}, {rand(4,1)}); T.Properties.VariableNames(end-1:end)=["A","B"] n=...

Expanding a cell array in table into multiple rows

Here's a scaled-down example: T=table(1,2,3,{rand(4,3)}, {rand(4,1)}); T.Properties.VariableNames(end-1:end)=["A","B"] n=...

2 months ago | 0

| accepted

Answered

Camera calibrator (picture capture)

Yes, for single camera calibration, it shouldn't matter whether the camera or the pattern (or both) are moving, as long as you d...

Camera calibrator (picture capture)

Yes, for single camera calibration, it shouldn't matter whether the camera or the pattern (or both) are moving, as long as you d...

2 months ago | 0

Answered

User Defined Functions in MATLAB

prodby2_kweave19(6) function product = prodby2_kweave19(N) product = prod(1:2:N); % User inputs N, as the argument to the...

User Defined Functions in MATLAB

prodby2_kweave19(6) function product = prodby2_kweave19(N) product = prod(1:2:N); % User inputs N, as the argument to the...

2 months ago | 0

| accepted

Answered

Increasing lsqcurvefit/nlinfit speed

It would definitely be faster to attach the table as an external variable to an anonymous or nested function, than to freshly lo...

Increasing lsqcurvefit/nlinfit speed

It would definitely be faster to attach the table as an external variable to an anonymous or nested function, than to freshly lo...

2 months ago | 0

| accepted

Answered

How to interpolate one axis in a 3D data?

load dats; F=griddedInterpolant(ss); ss=F({1:139,1:48, linspace(1,9,100)});

How to interpolate one axis in a 3D data?

load dats; F=griddedInterpolant(ss); ss=F({1:139,1:48, linspace(1,9,100)});

2 months ago | 0

| accepted

Answered

Using lsqnonneg to determine if there exists a solution to a (generally) under-determined linear system, but error is too large to be convincing.

A better way to investigate the existence of a solution to Aeq*x=beq, x>=0 might be (as below) to find the minimum distance betw...

Using lsqnonneg to determine if there exists a solution to a (generally) under-determined linear system, but error is too large to be convincing.

A better way to investigate the existence of a solution to Aeq*x=beq, x>=0 might be (as below) to find the minimum distance betw...

2 months ago | 0

Answered

Using lsqnonneg to determine if there exists a solution to a (generally) under-determined linear system, but error is too large to be convincing.

There is nothing that can be inferred from the resnorm alone about the quality of the solution. 10^-3 is a very good result if t...

Using lsqnonneg to determine if there exists a solution to a (generally) under-determined linear system, but error is too large to be convincing.

There is nothing that can be inferred from the resnorm alone about the quality of the solution. 10^-3 is a very good result if t...

2 months ago | 0

Answered

Creating multiple cylinders in different coordinates

Using cylindricalFit() from this FEX download https://www.mathworks.com/matlabcentral/fileexchange/87584-object-oriented-tools-...

Creating multiple cylinders in different coordinates

Using cylindricalFit() from this FEX download https://www.mathworks.com/matlabcentral/fileexchange/87584-object-oriented-tools-...

2 months ago | 0