Hello all. I am trying to solve the system of linear equations define by CX = K over multiple iterations (300*delta_t). But my plot only plots the first time step. Can someone help me with understanding how I can fix this in my code below?
Thanks so much!
clear all close all clcN=5; u(1:1:N) = 0;u(N+1) = 1;delta_t = 20;
Below is the for loop im having trouble with
for t = 1:delta_t:300*delta_t G(t) = t/20; A(t) = G(t)/2; B(t) = 1 + G(t); for j = 2:1:N k(j) = ((1-G(t))*u(j))+((G(t)/2)*(u(j+1)+u(j-1))); end C = [A(t) B(t) 0 0; A(t) B(t) A(t) 0; 0 A(t) B(t) A(t); 0 0 A(t) B(t)]; k = [k(2); k(3); k(4); k(5)-A(t)]; X = C\k; x1 = [0; X; 1]; y = 0:1/5:1; plot(x1,y) end
Best Answer