function [R d] = MomentArea(M, EI, h, Ro, do)
% This function calculates the rotations and deflections along a flexural
% member given the bending moment vector, M, a distance step, h, initial 
% deflection and rotation at node 0, do, Ro, and the flexural rigidity, EI.

n = length(M);                  % number of stations
R = zeros(n,1);                 % vector of rotations
d = zeros(n,1);                 % vector of deflections

R(1) = Ro;                      % assign starting rotation and deflection
d(1) = do;

R = cumtrapz(M)*h/EI + Ro;     % Do moment area calcs
d = cumtrapz(R)*h;