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

4 years ago | 1

Answered
"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(...

4 years ago | 0

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

4 years ago | 0

| accepted

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

4 years ago | 0

| accepted

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

4 years ago | 1

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

4 years ago | 0

Answered
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

4 years ago | 0

| accepted

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

4 years ago | 0

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

4 years ago | 0

Answered
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,:)

4 years ago | 0

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

4 years ago | 0

| accepted

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

4 years ago | 0

| accepted

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

4 years ago | 2

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

4 years ago | 1

| accepted

Answered
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); ...

4 years ago | 0

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

4 years ago | 0

| accepted

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

4 years ago | 0

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

4 years ago | 0

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

4 years ago | 0

| accepted

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

4 years ago | 0

| accepted

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

4 years ago | 0

| accepted

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

4 years ago | 0

Answered
How to get energy using power summation equation in MATLAB?
t = [0 t]; E = sum(P.*diff(t))

4 years ago | 0

| accepted

Answered
Solve system of differential equations
x01=-5;y01=-7; x0=[x01,y01]'; beta=25; syms x1 y1 t x11=[x1,y1]'; c1=(1/2)*(x1-i*sin(t))^2+(3/2)*(y1-i*cos(t))^2; row=100*...

4 years ago | 0

| accepted

Answered
Loop to check if 2 conditions are true for values 1:n, (1:n)+1, (1:n)+2, etc. in a vector and save ID
for i=1:365-7+1 period = rainfall(i:i+6); sum_period = sum(period); n = numel(find(period>0)); if sum_period...

4 years ago | 0

| accepted

Answered
Use ode45 when I have a constant that varies over time.
n=10; xmin_in = 15; % Minimum inlet temperature xmax_in = 16; % Maximum inlet temperature T_in = xmin_in+ra...

4 years ago | 0

| accepted

Answered
Determine y for a function with a symbolic variable x
syms x F(x) = x.^2; F(0)

4 years ago | 0

Answered
Rotate the coordinate system to align an existing plane with Y'Z' plane
https://stackoverflow.com/questions/9423621/3d-rotations-of-a-plane But are you sure that the parabola in the YZ plane is not a...

4 years ago | 0

Answered
How to solve a system of differential equations using ode45 and vary the magnetic field and plot the solutions as a function of this field?
b=[0:0.1:10]; d0=0.2 wb=1 wd=wb-d0 wl=wb db=0.18 dd=0.05 a=0.02 Ua=0.15 Ub=0.02 g1= 0.001 g2=g1 g3= 0.0001 g4=g3 %...

4 years ago | 0

Answered
Problems with declaring the variable right
xg= 7*2*5*1*6*3; xh= 3/10; F1=3; F2=100; T= 1/500; fun = @(k1,i) xg*sin(2*pi*F1*(k1-i)*T); fun(14,0:14)

4 years ago | 0

Load more