Info

This question is closed. Reopen it to edit or answer.

Stretch peak to peak y-values to plot

1 view (last 30 days)
meihua
meihua on 6 Oct 2013
Closed: meihua on 31 Oct 2013
figure(1)
x =[0 pi/2 pi 3*pi/2 2*pi 5*pi/2 3*pi];
y = [0 1 0 -1 0 1 0];
bcs = csapi(x,y);
xx=linspace(0,3*pi,1000);
val=fnval(bcs,xx);
xbound=peakdet(val,.5);
period=val(:,xbound(1,1):xbound(2,1));
plot(period)
figure(2)
x2 =[0 pi/2-1.5 pi+1.5 3*pi/2 2*pi-1.5 5*pi/2+1.5 3*pi];
y = [0 1 0 -1 0 1 0];
bcs = csapi(x2,y);
xx=linspace(0,3*pi,1000);
val=fnval(bcs,xx);
xbound=peakdet(val,.5);
period=val(:,xbound(1,1):xbound(2,1));
plot(period)
peakdet is a useful script I found here: http://www.billauer.co.il/peakdet.html
The lengths of fig1 period=712, fig2 period=462. I want to stretch or compress one of these vectors so that they reach their peaks at the same indices=>period lengths are the same, while still keeping their shape. I tried interp1 but none of the methods plotted out the way I wanted it to. Is there some other function/trick I could try?

Answers (0)

This question is closed.

Tags

Products

Community Treasure Hunt

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

Start Hunting!