How do I shift and repeat the same function and then sum the total overlapping area under those curves?
2 次查看(过去 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!