Applying ode45 by giving input by different formula(collocation points)?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
RUPAL AGGRAWAL
am 3 Jan. 2023
Bearbeitet: Fifteen12
am 3 Jan. 2023
I am trying to olve ode y' = y+1 ( y is a function of x) using ode45 and the x span = [0 1]. But i want to find the value of y at x = (l - 0.5)/2m, where m = 2^j and j = 0,1,2,3,4,.. and l = 1,2,3,4,..
1 Kommentar
Akzeptierte Antwort
Fifteen12
am 3 Jan. 2023
Bearbeitet: Fifteen12
am 3 Jan. 2023
You can read more about specifying specific solution points for ode45 at this link (highlighted). In this case, you want to solve for all the values of x you're wanting to find values of y for, then add those values of x as a parameter for ode45. Something like this gives you the values for y at the specified values of x.
% Find time values (in this case x values)
n = 4;
l = 1:n;
j = 0:n-1;
m = 2.^j;
x = (l - 0.5) ./ (2 * m);
x = sort(x);
% Make dummy y function
y_prime = @(x) 1/3 * x^3;
y0 = 0;
% Run ODE45
[x, y] = ode45(@(x, y) y_prime(x), x, y0);
Note that I had to make some assumptions for this to work: I had to sort x to make it always increasing, and I assumed what you wanted y(x) to be, as well as your initial conditions for it.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!