Sum of rectangle function

4 次查看(过去 30 天)
Amir Delavari
Amir Delavari 2020-11-1
Hello, how can I create a sum of rectangles?

回答(1 个)

Ameer Hamza
Ameer Hamza 2020-11-1
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 个评论
Ameer Hamza
Ameer Hamza 2020-11-2
How the rect() function is defined?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by