Maintaining a number generated through randomization
Try rng('default') as the first line of your code.

8日 前 | 0

Help with matrix question
A=[16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1]; I = find(A>3 & A<10); [ro...

8日 前 | 0

| 採用済み

Left and right sides have a different number of elements?
"launch_angle" and thus "dv" are arrays. Thus the operation V(i + 1) = V(i) + dv; does not work at the three positions in yo...

8日 前 | 0

| 採用済み

For loop completing the wrong steps.
Level_Either_Side = [Level_Either_Side ; Sorted_Level(Position(1,p)-5:Position(1,p)+5,1)]; if 5 positions before and after e...

9日 前 | 1

| 採用済み

Linear regression returns NaN for one of five regressors
Adding columns 2,3,4 and 5 shows that the rank of the matrix [ones(size(x,1),1),x]; will be the same as the rank of x, namely...

9日 前 | 0

How can i convert array a= [1 0 -2] in a char b = '1 0 -2' ?
https://de.mathworks.com/help/matlab/ref/num2str.html

9日 前 | 0

Minimize difference between vectors by varying scalar
a = x_model\x minimizes norm(a*x_model - x) If you want to minimize the difference in another norm (e.g. max(abs(a*x_model-x)...

9日 前 | 0

| 採用済み

Сonvert the coefficients of the Hermite polynomial into a function
https://de.mathworks.com/help/symbolic/poly2sym.html https://de.mathworks.com/help/symbolic/sym.int.html

9日 前 | 0

fitting 3 sets of data simultaneously using "lsqcurvefit"
Define T = [t1;t2;t3] and OR = [or1;or2;o3] and treat [T,OR] just like you treated [t1;or1],[t2;or2],[t3;or3] . Wha...

9日 前 | 1

"Could not find a feasible initial point" error in GA.
The sum of the upper bounds you prescribe for your variables x(1),...,x(5) is smaller than -a6. But you want to have x(1) + x(...

9日 前 | 0

Error solving bvp4c - Singular jacobian
Try this code following John's suggestion: %Constants hb = 6.626e-34/(2*pi); m = 9*1.660538921e-27; w0 = 2e6*2*pi; Cc = (1....

10日 前 | 0

| 採用済み

Function inside the function
r=@(s,z) sqrt((s+s0).^2+(z+z0).^2); Ds=@(s,z)(c0x+A1x.*erf((r(s,z)+a1x)./b1x)+A2x.*erf((r(s,z)+a2x)./b2x)+A3x.*erf((r(s,z)+a3x)...

10日 前 | 0

| 採用済み

Evaluating a function with Matlab
Then you have to program it as t = 10; f = sign(t-16.82).*abs((t-16.82)/5.604).^1.576 An expression x^a for x<0 is comple...

10日 前 | 1

How to Solve matrix symbolically?
It can solve for scalars - and since both expressions are linear in the matrices, the scalar and the matrix solution coincide. ...

10日 前 | 0

For loop to take the average of previous 10 elements and next 10 elements in an array in each step
https://de.mathworks.com/help/matlab/ref/movmean.html

10日 前 | 0

| 採用済み

How do I count how many times in a row a value occurs?
A = [1 2 4 3 1 1 1 1]; Au = unique(A); count = arrayfun(@(i)numel(find(A==Au(i))),1:numel(Au)) output = [Au;count].' Your qu...

10日 前 | 0

Zeros from Trapz integration
Maybe you mean something like L = 2; %thickness [m] TL = 300; %surface T [K] T0x0 = 340;%T0(x=0) T0x = @(x) -182.22.*x.^3 + ...

10日 前 | 0

Reveresing the order of columns in an array
A = [1 2; 3 4; 5 6; 7 8; 9 10; 11 12]; perm = [1 6 5 4 3 2]; A = A(perm,:)

10日 前 | 0

How to code a certain part of this equation?
for i = 1:m-1 xmhalf = x(i); xphalf = x(i+1); B_agg(i) = 0.0; for k=1:m for j=k:m if v...

10日 前 | 0

| 採用済み

Swaping two columns randomly picked
A = rand(25,5); i = randsample(5,2); v = A(:,i(1)); A(:,i(1)) = A(:,i(2)); A(:,i(2)) = v; or simply A = rand(25,5); i =...

11日 前 | 0

| 採用済み

Imposing Constraint in FMINCON optimization problem.
Aeq = [zeros(1,N_plies),ones(1,N_plies)]; beq = 1.0;

11日 前 | 2

How to fit power law distribution on data set?
plfit is not an official matlab code. You can download it here: https://github.com/jblocher/matlab-network-utilities/blob/mast...

11日 前 | 1

| 採用済み

Raising a scalar to each element in a matrix
expm is incorrect, use exp. And you shouldn't divide by 0 - not for X and not for Y. x = linspace(1,50); y = linspace(1,50); ...

11日 前 | 0

Sinus plus straight lines plot
f = @(x) 2*sin((x+2)*pi/2).*(x>=-2).*(x<-1) + (-2*x).*(x>=-1).*(x<=0); x=-2:0.001:0; plot(x,f(x)) Can you add the next two cy...

11日 前 | 0

| 採用済み

Setting Initial Conditions for Genetic Algorithm
Here is a list of options (also for initial conditions) you can set for ga: https://de.mathworks.com/help/gads/ga.html#mw_4a8bf...

11日 前 | 0

possitive solution for set of three nonlinear eqations where t_1 t_2 and pi_2 are varaibles
Solve the first equation for t_i2. Solve the second equation for P_i2 and insert the expression for t_i2 from the first equatio...

11日 前 | 0

how to create an arc path from 3 points(x, y, z) in plane?
Determine the center of the circle: https://math.stackexchange.com/questions/1076177/3d-coordinates-of-circle-center-given-thre...

11日 前 | 0

| 採用済み

Ho to perform Monte Carlo Simulation with a factor and a vector.
data_TSS=readtable('turb_danuube_15min.csv'); % data TSS & time TSS=data_TSS(1:1:353665,2); time=data_TSS(1:1:353665,1); %% T...

11日 前 | 0

| 採用済み

A simple error minimization (optimization) problem
A = [C1,C2,C3]; b = L1+L2+L3; C = A\b; C1 = C(1) C2 = C(2) C3 = C(3)

11日 前 | 0

| 採用済み

while loop to count partail sum of series
sum_{i=1}^{i=N} 1/(i*(i+1)) = 1 - 1/(N+1) No need for such a difficult while construction with precision estimate.

12日 前 | 0