Answered

How do I plot a 1-d random walk that generate 1 and -1 with equal probability? I am struggling to plot every individual P that I get against i the number of step.

n = 10; P = zeros(n,1); P(1) = 0; % Starting value for i=2:n % i is the number of steps from 1 to 10 R = rand; if R ...

How do I plot a 1-d random walk that generate 1 and -1 with equal probability? I am struggling to plot every individual P that I get against i the number of step.

n = 10; P = zeros(n,1); P(1) = 0; % Starting value for i=2:n % i is the number of steps from 1 to 10 R = rand; if R ...

20 hours ago | 0

| accepted

Answered

How to define multi variable linear programming ??

Set Z0 = x4, Z1= x5, Z2 = x6. Can you solve the problem now ?

How to define multi variable linear programming ??

Set Z0 = x4, Z1= x5, Z2 = x6. Can you solve the problem now ?

24 hours ago | 0

Answered

Error using bvp4c: "Warning: Unable to meet the tolerance without using more than 5000 mesh points. The last mesh of 4921 points and the solution are available in the output argument."

If the code works for values of L0 smaller than 100, try approaching 100 by subsequently calling bvp4c with values L0start, L01,...

Error using bvp4c: "Warning: Unable to meet the tolerance without using more than 5000 mesh points. The last mesh of 4921 points and the solution are available in the output argument."

If the code works for values of L0 smaller than 100, try approaching 100 by subsequently calling bvp4c with values L0start, L01,...

24 hours ago | 0

Answered

How can i generate random numbers according to a known probability?

https://en.wikipedia.org/wiki/Inverse_transform_sampling

How can i generate random numbers according to a known probability?

https://en.wikipedia.org/wiki/Inverse_transform_sampling

2 days ago | 0

Answered

Convert this C program into matlab. Please help. Stuck very badly as con[i][j] matrix is showing decimal nos. like 23.33(which is obviously not accepted in indexing in matlab).That error is showing in MG_matrix[con[eltn][i] - 1][con[eltn][j] - 1]

for i=1:30 for j=1:27 conn(i,j) = 58*floor((j-1)/3)+(j-1)+2*(i-1)+1 end end for i=1:27 for j=1:27 MG_mat...

Convert this C program into matlab. Please help. Stuck very badly as con[i][j] matrix is showing decimal nos. like 23.33(which is obviously not accepted in indexing in matlab).That error is showing in MG_matrix[con[eltn][i] - 1][con[eltn][j] - 1]

for i=1:30 for j=1:27 conn(i,j) = 58*floor((j-1)/3)+(j-1)+2*(i-1)+1 end end for i=1:27 for j=1:27 MG_mat...

2 days ago | 0

| accepted

Answered

Why is the fval value so large when I use fzero to solve a equation which has Elliptical integral？

[betaxx,fval]=fzero(f1,[pi/2+0.01,3*pi/2-0.01])

Why is the fval value so large when I use fzero to solve a equation which has Elliptical integral？

[betaxx,fval]=fzero(f1,[pi/2+0.01,3*pi/2-0.01])

3 days ago | 0

| accepted

Answered

How can I work out the rate of change for my experimental data?

rate_of_change_of_altitude = diff(altitude)./diff(time)

How can I work out the rate of change for my experimental data?

rate_of_change_of_altitude = diff(altitude)./diff(time)

3 days ago | 0

| accepted

Answered

Fit an Ordinary Differential Equation (ODE) using lsqcurvefit

Remove parameters x(1) and x(2) from your list and introduce one new variable x(12). From x(12), calculate x1=5*cos^2(x(12)) and...

Fit an Ordinary Differential Equation (ODE) using lsqcurvefit

Remove parameters x(1) and x(2) from your list and introduce one new variable x(12). From x(12), calculate x1=5*cos^2(x(12)) and...

3 days ago | 1

Answered

Solving ODEs with different sets of initial conditions

function main n_times = 1000; t_i = 1; t_f = 10; tspan = [t_i,t_f]; y0 = randn(2, n_times); y0 = reshape(y0, 2*n_tim...

Solving ODEs with different sets of initial conditions

function main n_times = 1000; t_i = 1; t_f = 10; tspan = [t_i,t_f]; y0 = randn(2, n_times); y0 = reshape(y0, 2*n_tim...

3 days ago | 0

| accepted

Answered

How do I output the second derivative from an ODE solver for further use?

After the line [t, r] = ode45('bubble', time_range, initial_conditions); insert for i=1:numel(t) t_actual = t(i); r_act...

How do I output the second derivative from an ODE solver for further use?

After the line [t, r] = ode45('bubble', time_range, initial_conditions); insert for i=1:numel(t) t_actual = t(i); r_act...

3 days ago | 0

| accepted

Answered

How to solve first-order Taylor series expansion of two variable in MATLAB ?

https://de.mathworks.com/matlabcentral/answers/92764-how-do-i-generate-the-taylor-series-as-a-function-of-several-variables-in-m...

How to solve first-order Taylor series expansion of two variable in MATLAB ?

https://de.mathworks.com/matlabcentral/answers/92764-how-do-i-generate-the-taylor-series-as-a-function-of-several-variables-in-m...

3 days ago | 0

Answered

How to evaluate a point in a solved differential equation in matlab?

y16 = interp1(xx,yy,1.6)

How to evaluate a point in a solved differential equation in matlab?

y16 = interp1(xx,yy,1.6)

4 days ago | 1

Answered

singular jacobian encountered with bvp4c : constant-dependant result

function dydx = diffeq(x,y) % the function vector is as follows : y = [g; dg/dx; f; df/dx; h; dh/dx] dydx=ones(length(y),1); ...

singular jacobian encountered with bvp4c : constant-dependant result

function dydx = diffeq(x,y) % the function vector is as follows : y = [g; dg/dx; f; df/dx; h; dh/dx] dydx=ones(length(y),1); ...

4 days ago | 0

Answered

Finding the multiple zeros within a prescribed interval

deltax = 1e-4; xright = 100; n = floor(xright/pi); fun = @(x)tan(x)-x; for i=1:n left = (2*i-1)*pi/2.0 + deltax; right...

Finding the multiple zeros within a prescribed interval

deltax = 1e-4; xright = 100; n = floor(xright/pi); fun = @(x)tan(x)-x; for i=1:n left = (2*i-1)*pi/2.0 + deltax; right...

4 days ago | 1

Answered

Solution of mincon doesn't satisfy the nonlcon constraints

function main x0 = [1,1] A = [0 1] b = [40] lb = [0 0] ub = [10000 10000] [x,fval] = fmincon(@objfun,x0,A,b,[]...

Solution of mincon doesn't satisfy the nonlcon constraints

function main x0 = [1,1] A = [0 1] b = [40] lb = [0 0] ub = [10000 10000] [x,fval] = fmincon(@objfun,x0,A,b,[]...

4 days ago | 0

Answered

Stuck on rewriting program to use nested if constructs

if x>=0 if y>=0 ...; else ...; end else if y>=0 ...; else .....

Stuck on rewriting program to use nested if constructs

if x>=0 if y>=0 ...; else ...; end else if y>=0 ...; else .....

5 days ago | 0

Answered

How to implement tightly coupled nonlinear odes using ode45 in matlab?

Solve the equations t*x2 - x1*x2' = t^2*x1 + x2*x1' x1'' + x2'' = t*x2 - x1*x2' Setting y1 = x1 y2 = x1' ...

How to implement tightly coupled nonlinear odes using ode45 in matlab?

Solve the equations t*x2 - x1*x2' = t^2*x1 + x2*x1' x1'' + x2'' = t*x2 - x1*x2' Setting y1 = x1 y2 = x1' ...

5 days ago | 0

| accepted

Answered

Calculate the integral in time of a variable that's being integrated with ODE15s

Add the equation d(tau)/dt = R^4 with tau(0) = 0 Then tau is available during integration. Best wishes To...

Calculate the integral in time of a variable that's being integrated with ODE15s

Add the equation d(tau)/dt = R^4 with tau(0) = 0 Then tau is available during integration. Best wishes To...

5 days ago | 0

Answered

Warning: Cannot find explicit solution

format long deltax = 1e-13; n = 100; ke = 3.7e-5; R = 2e-4; Dm = 12.6e-19; fun = @(x)x.*cot(x)-1+ke*R/Dm; ...

Warning: Cannot find explicit solution

format long deltax = 1e-13; n = 100; ke = 3.7e-5; R = 2e-4; Dm = 12.6e-19; fun = @(x)x.*cot(x)-1+ke*R/Dm; ...

5 days ago | 0

Answered

ode45 say that return column vector using lsqcurvefit

function FF = BF(velocity1, a, dk1) n = 1; t_int = (0:0.0006:5.3994)'; velocity1_int = velocity1'; [xa] = ode4...

ode45 say that return column vector using lsqcurvefit

function FF = BF(velocity1, a, dk1) n = 1; t_int = (0:0.0006:5.3994)'; velocity1_int = velocity1'; [xa] = ode4...

5 days ago | 0

| accepted

Answered

I am having trouble writing a ODE45 function for this bungee jumping problem.

Take a look at the ballode example: https://www.mathworks.com/examples/matlab/mw/matlab-ex84325677-simple-event-location-a-bo...

I am having trouble writing a ODE45 function for this bungee jumping problem.

Take a look at the ballode example: https://www.mathworks.com/examples/matlab/mw/matlab-ex84325677-simple-event-location-a-bo...

5 days ago | 0

Answered

ode23: using different sets of ODE equations at certain time intervals t

Take a look at the answer given here: https://de.mathworks.com/matlabcentral/answers/429332-using-ode45-to-solve-quarter-mode...

ode23: using different sets of ODE equations at certain time intervals t

Take a look at the answer given here: https://de.mathworks.com/matlabcentral/answers/429332-using-ode45-to-solve-quarter-mode...

5 days ago | 0

Answered

Using ODE45 to solve quarter model of suspension with input function (an endless obstacle)

t = 0:0.01:0.25; phase = 1; y0 = [0 0 0 0]; [t1, y1] = ode45(@(t,y) fce(t,y,phase),t,y0); t = 0.25:0.01:3; ph...

Using ODE45 to solve quarter model of suspension with input function (an endless obstacle)

t = 0:0.01:0.25; phase = 1; y0 = [0 0 0 0]; [t1, y1] = ode45(@(t,y) fce(t,y,phase),t,y0); t = 0.25:0.01:3; ph...

5 days ago | 0

Answered

Parameter fitting problem: I use lsqnonlin to fit 3 parameters into a system of ODES and everything works fine until I inserted a Confidence Interval as one of my coefficients.At that point the fitted parameter vector took only the initial guess

Each time your ODE function is called, "rand" takes a different value between 0 and 1. This makes it impossible for the ODE solv...

Parameter fitting problem: I use lsqnonlin to fit 3 parameters into a system of ODES and everything works fine until I inserted a Confidence Interval as one of my coefficients.At that point the fitted parameter vector took only the initial guess

Each time your ODE function is called, "rand" takes a different value between 0 and 1. This makes it impossible for the ODE solv...

8 days ago | 0

| accepted

Answered

Minimize non linear function with undefined vector

The examples given here should show you how to proceed: https://de.mathworks.com/help/matlab/ref/fminsearch.html

Minimize non linear function with undefined vector

The examples given here should show you how to proceed: https://de.mathworks.com/help/matlab/ref/fminsearch.html

8 days ago | 0

| accepted

Answered

How we can solve the symbolic integral of the given function

Your integral equals b^(a+1)*(c/b*gamma(a)*gammainc(c/b,a)-gamma(a+1)*gammainc(c/b,a+1)) Best wishes Torsten.

How we can solve the symbolic integral of the given function

Your integral equals b^(a+1)*(c/b*gamma(a)*gammainc(c/b,a)-gamma(a+1)*gammainc(c/b,a+1)) Best wishes Torsten.

8 days ago | 0

Answered

Solving linear convection equation (wave equation) by Lax Wendroff Scheme

N=100; %No. of grid points Tmax=1; % time period=1 alpha=1; %given h=0.01; %given value of delX delt=0.005; ...

Solving linear convection equation (wave equation) by Lax Wendroff Scheme

N=100; %No. of grid points Tmax=1; % time period=1 alpha=1; %given h=0.01; %given value of delX delt=0.005; ...

8 days ago | 1

| accepted

Answered

How to fit a custom probability distribution to my data?

Since the integral from 0 to Inf must be equal to 1, it follows that a = b = lambda. This is the usual exponential distribution ...

How to fit a custom probability distribution to my data?

Since the integral from 0 to Inf must be equal to 1, it follows that a = b = lambda. This is the usual exponential distribution ...

8 days ago | 1

| accepted

Answered

How to stop the ODE45 at a defined condition during its execution ?

If you want a controlled shutdown, use the event function capability of the ODE solvers.

How to stop the ODE45 at a defined condition during its execution ?

If you want a controlled shutdown, use the event function capability of the ODE solvers.

8 days ago | 2

Answered

How to insert square terms in constraints for fmincon

You must use function "nonlcon" for this.

How to insert square terms in constraints for fmincon

You must use function "nonlcon" for this.

9 days ago | 0