Answered
Error with ode45 when using a decreasing x value: more non-singleton rhs dimensions than non-singleton subscripts
function main tspan=linspace(8,0.2,78); y0=6; [t,y]=ode45(@fun2,tspan,y0) function f = fun2(t,y) f=-sqrt(1...

8 years ago | 1

| accepted

Answered
how to get the second variable in a function?
[A_output,B_output] = par(20,5); And name input and output variables differently in par and par2. Best wishes Torsten. ...

8 years ago | 0

| accepted

Answered
How to solve two differential equations using ode45.
fun=@(t,y)[y(2);-y(2)-y(1)-y(4);y(4);-y(4)-y(3)-y(2)]; x0=...; %supply x(t0) x0prime=...; %supply x'(t0) y0=...;...

8 years ago | 5

| accepted

Answered
i have written a code to get LU decomposition,now i need a code to solve LUx=b
First solve L*y = b for y, then solve U*x = y for x. Best wishes Torsten.

8 years ago | 0

| accepted

Answered
Maximizing value for an array with integral function.
fmax = -Inf; for t1=1:numel(t)-10 fmax = max((trapz(t(t1:t1+10),A(t1:t1+10)))^2.5*(t(t1+10)-t(t1)),fmax); end fm...

8 years ago | 0

| accepted

Answered
How to solve exponential equation in Matlab?
Substitute y = exp(-0.1*x). Your equation now becomes y^10 + y = 0.5 Use MATLAB's "roots" to solve for y. ...

8 years ago | 1

Answered
How do I solve a system of differential equations with initial conditions to the second derivative?
constr_Ax, constr_Ay, constr_Bx and constr_By give you x1, x2, y1 and y2 depending on theta1 and theta2 (linear system of equati...

8 years ago | 0

| accepted

Answered
Determine if valid initial guess for closed numerical method
If you want to use "fzero", you can first evaluate f in the endpoints of the interval [a b] you provide. If sign(f(a)*f(b)) < 0,...

8 years ago | 0

Answered
dsolve and heaviside (unit step response)
Why Y(0)=0.5 ? Y(0) = sign(0)/2-exp(-0)/2+1/2 = 0-1/2+1/2 = 0. Best wishes Torsten.

8 years ago | 0

Answered
How do I prepare the following ODE for ode45?
fun = @(x,y)[y(2);y(3);y(1)*(2+x^2)]; y0 = [0 0 0]; xspan = [0 5]; [X,Y] = ode45(fun,xspan,y0); plot(X,Y(:,1),X,Y(...

8 years ago | 1

| accepted

Answered
Index exceeds matrix dimensions using fsolve
function main guess = [120, 17]; xsol = fsolve(@position4,guess ) function F = position4(x) F(1) = 40*cos(50* ...

8 years ago | 0

| accepted

Answered
How can I solve a system of coupled differential equations?
If you set dx/dt = y1, theta = y2, dtheta/dt = y3, then you have to solve y1' = y1^2 y2' = y3 y3' = y1...

8 years ago | 0

| accepted

Answered
Saving the last value of a loop that will run 100 times
step = zeros(100,1); for k=1:100 x=0; step_actual=0; while (x<10)&&(x>-10) step_actual = step_actual+...

8 years ago | 0

| accepted

Answered
fmincon, quadprog or other
Use "lsqcurvefit". Best wishes Torsten.

8 years ago | 0

Answered
How to obtain a numeric value of an integral involving 3 variables and a bessel function?
function main a = 17.6e-6; lambda = 1.0084; h = a; x = ...; y = ...; int_w_z = 2/pi*integral(@(s)w_z(s,lambd...

8 years ago | 0

| accepted

Answered
fsolve system of nonlinear equations with variable parameters
function main theta_i=[1 2 3 4 5 6 7 8 9 10]; x0 = [1 1 1 1]; for k=1:numel(theta_i) theta_i_actual = theta_i(k)...

8 years ago | 2

| accepted

Answered
Double integral with limit with Monte Carlo simulation
Hint: Use polar coordinates. Best wishes Torsten.

8 years ago | 0

Answered
How to solve heat equation on matlab ?
Use MATLAB's "pdepe". Best wishes Torsten.

8 years ago | 0

Answered
Implementation of mixed boundary conditions with finite difference methods
Try npoints = 301; xleft = 0.0; xright = 10.0; deltax = (xright-xleft)/(npoints-1); x = zeros(npoints,1) ...

8 years ago | 0

Answered
How can i solve a system coupled of PDE with an ODE using finite difference?
Take a look at the answer provided here: https://de.mathworks.com/matlabcentral/answers/371313-error-in-solving-system-of-two...

8 years ago | 0

| accepted

Answered
How do I find the maximum value produced in a loop?
max_s = -1; for k=1:N; x = sign(rand-0.5); if x==1 s = s+1; elseif x==-1 disp...

8 years ago | 0

| accepted

Answered
matrix retrieving given certain determinant
determinant = -30; diagonal = abs(determinant)^(1/3); A = zeros(3); A(1,1) = diagonal; A(2,2) = diagonal; A(3,3...

8 years ago | 0

Answered
Error using pdepe function in matlab.
Call pdepe in a loop for M = M_array(1),M = M_array(2),... Best wishes Torsten.

8 years ago | 0

Answered
Optimisation algorithms for a non-linear function with integer variables?
If the number of possible combinations of the 6 integers is not too big, you can try them all to get the minimum. Best wishes...

8 years ago | 0

Answered
how to create this matrix [1 2 3 4 5;2 2 3 4 5;3 3 3 4 5;4 4 4 4 5;5 5 5 5 5]
A = [1 2 3 4 5;2 2 3 4 5;3 3 3 4 5;4 4 4 4 5;5 5 5 5 5]; Best wishes Torsten.

8 years ago | 0

Answered
How can I make a bvp4c solution more stable?
Thanks for the detailed explanation of the problem. I used the following problem formulation in COMSOL Multiphysics and it wo...

8 years ago | 0

| accepted

Answered
I'm very new to matlab and I'm doing this simulation for infectious diseases. I keep receiving an error message: Not enough input arguments." Error in sird (line 47) dx(1)= -beta*(x(2)*x(1))/x(5)+x(1)*(dr+br);" How do I solve this?
Try the following function file: function main tspan=linspace(0,30,210); options= odeset('RelTol', 1e-4, 'NonNegative...

8 years ago | 0

| accepted

Answered
solution of a polynomial equation.
help fsolve Best wishes Torsten.

8 years ago | 1

Answered
How can I make a bvp4c solution more stable?
You must specify the retentate molar flows at x=0 in the boundary routine of bvp4c, not in the routine where you specify the ODE...

8 years ago | 0

Answered
How many Minimum Non Linear equations required to solve N variables in optimization problem?
Any number of constraint functions is ok. Best wishes Torsten.

8 years ago | 0

Load more