Subtracting the two resulting graghs of my ode program
7 views (last 30 days)
I have two second order differential equations. I solved them with Ode45, but I want to subtract the two resulting answers from each other and plot the subtraction of the one answer from another one. How can I do that???
[T,Y]=ode45(@function1,[0 10],[0 0]);
[M,X]=ode45(@function2,[0 10],[0 0]);
I want to plot X(:,1)-Y(:,1)???
Kelly Kearney on 6 Jul 2016
You can either change the second input of both ode45 calls to specify specific time values to output:
tspan = linspace(0,10,100);
(Here, T, M, and tspan will be equal).
Or, you could keep your original input but interpolate both output timeseries to the same grid:
y2 = interp1(T, Y, tspan);
x2 = interp1(M, X, tspan);