Answered
How to find values of variables?
Try X = null(Q.') Best wishes Torsten.

7 years ago | 2

| accepted

Answered
Time derivative of parameters within ODE solvers
function dy = ODE(t,y) dt = 1e-8; fm = myfun(t-dt); f = myfun(t); fp = myfun(t+dt); df = (fp - fm) / (2 * dt); ...

7 years ago | 0

| accepted

Answered
is it possible to change step size of "ode45" ?
The stepsize of ode45 is not constant, but chosen such that the error tolerances you prescribe are met. Thus mean step size can ...

7 years ago | 2

| accepted

Answered
Common error message: "Index exceeds matrix dimensions"
"Market_Price" is a one-dimensional array ; you try to access "Market_Price(t,k)".

7 years ago | 0

| accepted

Answered
Problem while solving the problem ode45
[t,y]=ode45(@(t,y)pair(t,y,a,b,c),tspan,[2 4]); function dy=pair(t,y,a,b,c) dy(1)= -a.*y(1)+b*exp(-t); dy(2)=(-y(1).*y(2).^...

7 years ago | 0

Answered
How to sum and plot a series of functions?
n = 24; k = 1:n; part1 = @(x) sin(k*x) part2 = (2/pi*(1-(-1).^k)./k).'; x = linspace(0,2*pi,100); Snx = arrayfun(@(x)part1(...

7 years ago | 1

| accepted

Answered
How to use linear programming to solve following minimisation problem: min C'x subject to Ax - sum(x)b ≤ 0
The constraints read A'*x <= 0 with elements a'(i,j) = a(i,j) - b(i) Best wishes Torsten.

7 years ago | 2

| accepted

Answered
Index in position 1 exceeds array bounds (must not exceed 5)
In the stated expression, you try to use Q(6,1) which is undefined. (In the top loop, Q(i,1) is only initialized up to Q(5,1)). ...

7 years ago | 0

| accepted

Answered
Finding maximum integer between [100,200] divisible by 21?
n = 200 - mod(200,21)

7 years ago | 0

Answered
Find the minimum of a multivariable anonymous function + error message
v = fminsearch(@(x)y(x(1),x(2)),v0);

7 years ago | 0

Answered
Could someone please help me fix this code?
function main %% preparations a=0; b=10; N=100; % t0, t final, N values h=(b-a)/N; % step si...

7 years ago | 0

| accepted

Answered
help, my ode is not working. First will be my main code. Second will be the function I am calling for.
The last argument (cd) is missing in the call to "dynamiteff" in the line [t1,vel1]=ode45(@(t1,s) dynamiteff(t,s(1),s(2),timeto...

7 years ago | 0

Answered
How to solve system of non linear hyperbolic equations, where the hyperbola orientations may not be parallel with axes.
fun = @(x,y) (sqrt((0-x(1))^2+(9-x(2))^2)-sqrt((0-x(1))^2+(0-x(2))^2)-2.214)^2+(sqrt((12-x(1))^2+(0-x(2))^2)-sqrt((0-x(1))^2+(0-...

7 years ago | 0

Answered
Use previous calculated value in ODE as guess in current timestep
The easiest way is to include the algebraic equation for pressure in the system solved by the ODE integrator. Note that the ODE ...

7 years ago | 0

Answered
Error: Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
Print the "res"-vector, and you'll probably find the problem. I guess some elements of the res-vector will be NaN or Inf values....

7 years ago | 0

Answered
Calculating arc length of a curve
Use Pythagoras' theorem: n = numel(x); length = 0.0; for i = 1:n-1 length = length + sqrt( (x(i+1)-x(i))^2 + (y(i+1)-y(i)...

7 years ago | 2

| accepted

Answered
find the maximum value of a function
The maximum value for diff(y,2) is attained in x=b with value -(14/(14*b+30))^2.

7 years ago | 3

Answered
Fit an Ordinary Differential Equation (ODE) using fmincon
function main % ydata from excel filename = 'Messung_1.xlsx'; sheet = 12; Range1 = 'C6:C3790'; Range2 = 'D6:C3790'; t_Kl ...

7 years ago | 0

| accepted

Answered
eigenvalues and eigenvector manual calculation
By solving (A-lambda1*I)*v1 = 0 and (A-lambda2*I)*v2 = 0 You could use v1 = null(A-lambda1*I) and v2 = null(A-lambda2*I) ...

7 years ago | 2

| accepted

Answered
Solving differential equation that includes an (extra) unknown function
Take a look at the example ODE with Time-Dependent Terms under https://de.mathworks.com/help/matlab/ref/ode45.html I will s...

7 years ago | 1

| accepted

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

7 years ago | 1

| accepted

Answered
How to define multi variable linear programming ??
Set Z0 = x4, Z1= x5, Z2 = x6. Can you solve the problem now ?

7 years 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,...

7 years ago | 0

Answered
How can i generate random numbers according to a known probability?
https://en.wikipedia.org/wiki/Inverse_transform_sampling

7 years ago | 0

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

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

7 years ago | 4

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

7 years ago | 1

| accepted

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

7 years ago | 1

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

7 years ago | 0

| accepted

Load more