So I have this function where I'm calculating the values of the U matrix at each t value (0,1,2,etc.). The problem I'm having is that the function only returns the final value for U, and does not return t value. To illustrate what I'm trying to get, here's an example:
t x y0 2 11 2.6 0.92 3.458 0.891
etc.
function [U,t] = IVP(a,b,c)syms x y h t;h=c;x=a;y=b; for t=0:1:30 f=[1.2*x-0.6*x*y;0.3*x*y-0.8*y]; u=[x;y]; U=u+h*f; x=U(1); y=U(2);endend
Best Answer