How do I shift and repeat the same function and then sum the total overlapping area under those curves?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Walter Roberson
am 3 Nov. 2017
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))
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!