Solution Codes of Ordinary Diferenatial Equation
6 views (last 30 days)
I wrote MATLAB codes for
equation with parameter n=450, a= -1.99 and x_0=3/4 as follows.
clc; clear; clear all;
But with the same parameters and in the equation above at two places division by 4, i couldn't arrange MATLAB codes. Please, help me.
Jan on 21 May 2022
Edited: Jan on 21 May 2022
What is the purpose of the outer loop "for p=1:k"? Why does the inner loop "for n=0:p-2" run from 0 to p-2?
It is confusing that you've swapped n and k.
The purpose of your code is not clear to me. I have no idea, why inserting /4 twice is a problem and why you assume, that the graph is "not correct". I cannot guess what you expect instead.
n = 450;
a = -1.99;
x0 = 0.75;
T = linspace(0, 1000, 1000);
X = 1 + a * T;
for k = 0:n
X = X + a^2 * (1 + a / 4)^k * (T - (k + 1) / 4);
X = X * x0;