Effacer les filtres
Effacer les filtres

Applying ode45 by giving input by different formula(collocation points)?

1 vue (au cours des 30 derniers jours)
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 commentaire
Fifteen12
Fifteen12 le 3 Jan 2023
What have you tried so far? What problems are you encountering?

Connectez-vous pour commenter.

Réponse acceptée

Fifteen12
Fifteen12 le 3 Jan 2023
Modifié(e) : Fifteen12 le 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.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by