Sum of rectangle function

Hello, how can I create a sum of rectangles?

Respuestas (1)

Ameer Hamza
Ameer Hamza el 1 de Nov. de 2020

0 votos

If by "sum of rectangles" you mean Riemann sum approximation of integral using rectangles, then use cumsum(): https://www.mathworks.com/help/matlab/ref/cumsum.html. For example
t = 0:0.1:10;
y = t.^2;
I = cumsum(y).*gradient(t);

5 comentarios

Amir Delavari
Amir Delavari el 1 de Nov. de 2020
My task is to create a sum of rectangular pulse functions
Ameer Hamza
Ameer Hamza el 1 de Nov. de 2020
Can you show the mathematical formula for the function?
Amir Delavari
Amir Delavari el 1 de Nov. de 2020
Ameer Hamza
Ameer Hamza el 2 de Nov. de 2020
How the rect() function is defined?

Iniciar sesión para comentar.

Categorías

Más información sobre Numerical Integration and Differential Equations en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 1 de Nov. de 2020

Comentada:

el 2 de Nov. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by