Hello, how can I create a sum of rectangles?

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 11월 1일

0 개 추천

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

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

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

질문:

2020년 11월 1일

댓글:

2020년 11월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by