Using MATLAB's command of "ODE45", generate plots of H1(t) and H2(t) on the same graph given the following information
H1= 10
H2= 5
H1' (aka the derivative of h1) = -Q / 19.6
H2' = Q/19.6
Q= 0.015 (H1-H2)
Include your entire code and the picture of the graph it provides
Code:
clear all;
clc;
% Since diffrential equations for H1' and H2' are interdependent via Q,
% so they will be solved simulatneosuly
% given system of diffrential equations
f = @(t,x) [(-0.015*(x(1)-x(2)))/19.6; (0.015*(x(1)-x(2)))/19.6];
% solve the system using ode45
tspan = [0 5];
y0 = 0;
[t,y] = ode45(@(t,y) (-0.015*(x(1)-x(2)))/19.6, tspan, y0);
[t,xa] = ode45(f,[0 1.5],[10 5]);
% plot the solution
plot(t,xa(:,2))
title('y(t)')
xlabel('t'), ylabel('y')
grid on
Get Answers For Free
Most questions answered within 1 hours.