How do I shift and repeat the same function and then sum the total overlapping area under those curves?
조회 수: 3 (최근 30일)
이전 댓글 표시
I have a function which is similar to this
x=-10:0.1:10;
y=sqrt((36-x.^2)/9);
plot(x,y)
I would like to shift it by 1 and repeat this 20 times (so that I have as many repeats as values of x). I tried with things like circshift and this:
A=[1 2 3 4 5]
B=zeros(size(A));
n=1; %Shift units
B(n+1:end)=A(1:end-n)
but I'm stuck. Once I have that, I'd like to calculate the sum of all the overlapping areas in a certain range (say -10:0). But that is even further away from my skills... any tip is appreciated!
댓글 수: 0
답변 (1개)
Walter Roberson
2017년 11월 3일
x=-10:0.1:10;
A = sqrt((36-x.^2)/9);
N = length(x);
B = zeros(length(x) + N);
for shift = 1 : N
B(shift : shift+N-1) = B(shift : shift+N-1) + A;
end
plot(real(B))
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!