Sum of rectangle function

4 visualizaciones (últimos 30 días)
Amir Delavari
Amir Delavari el 1 de Nov. de 2020
Comentada: Amir Delavari el 2 de Nov. de 2020
Hello, how can I create a sum of rectangles?
  1 comentario
Ameer Hamza
Ameer Hamza el 1 de Nov. de 2020
What do you mean by sum of rectangles?

Iniciar sesión para comentar.

Respuestas (1)

Ameer Hamza
Ameer Hamza el 1 de Nov. de 2020
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
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 Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by