Is there a way to plot my Euler outputs in a graph with the code i currently have?

18 Views Asked by At

enter image description here

%%%%% MATLAB function to perform Euler's method
% File Name: euler.example.m
function[U]=euler_exampleF21(x,t,tfinal,n) %x is the dependent (output), t is independent
    format long
    h=(tfinal-t)/n; %determines time-step step delta t
    % capital T,X is non iterative
    f=@(T,X)exp(T)*cos(X); %given in standard form
    U=zeros(n,2); %U stores a matrix
    for i=1:n+1
        U(i,:)=[t,x];
        x=x+h*f(t,x); %iterative process
        t=t+h; %increase time-step
    end
    W=U(n+1,:);