MATLAB: How do integrate this function over t=0 to t=165

integrationnumerical integration

mi=2290000;
mf=130000;
tb=165;
t=linspace(6.5,165);
mr=mi-((mi-mf)*(t/tb))
plot(t,mr, 'blue')
hold all
g = 9.81;
Isp=263;
u=g.*(Isp.*log(mi./mr)-t)

Best Answer

I am not certain what you want to integrate, or what you want the final result to be.
Try this:
mi=2290000;
mf=130000;
tb=165;
t = linspace(0, tb, 150);
mr = mi-((mi-mf)*(t/tb));
mr_int = cumtrapz(t, mr); % Integrate ‘mr’
figure
semilogy(t,mr, 'blue')
hold on
plot(t, mr_int, 'g')
g = 9.81;
Isp=263;
u = g.*(Isp.*log(mi./mr)-t);
u_int = cumtrapz(t, u); % Integrate ‘u’
plot(t, u)
plot(t, u_int)
hold off
legend('mr', 'mr\_int', 'u', 'u\_int', 'Location','SE')
I ploltted the vectors in semilogy so they would all be visible.
Experiment to get different results.