MATLAB help, plotting an ode!?

azndude62

New member
i need help plotting a solution to an ordinary differential equation using matlab. my assignment is to plot the solutions to two ODEs using one function file on the same plot.i made the function file but i not know how to plot both solutions.

here is my function file:


function [ydot1,ydot2] = odefun2b(t,y);
ydot1= 1-y*(t/2);
ydot2= 1-(y^2)*(t/2);
end
here is the code to the script:
y0=1;
tspan = [0 10];
[t,y]=ode45(@odefun2b,tspan,y0);
plot(t,y)
xlabel('t')
ylabel('y')

when i test it only the plot of ydot1 appears, i don't know how to make the plot of ydot2 appear. like i said i can only use one function file. otherwise i could have easily used 'hold on' and used another function to put them on the same plot. please help. thank you!
 
Back
Top