How to select data points for interpolation

I am trying to interpolate between two points on my sinosoidal shaped graph. How do I select a desired range of points on that graph to interpolate from? I've tried using 'point(1): point(1)+5' but this is taking 5 numbers greater than point(1) and increasing by 1. ex: if the value of my point is 100.5 I get [100.5,101.5,102.5,103.5,104.5,105.5]. Instead I want to get the 5 data points which procede point(1).

댓글 수: 1

Fadi Lama
Fadi Lama 2020년 12월 5일
I don't know how to explain but point(1) is basically a peak so pks(1). I want to include the 5 proceding points which are basically magnitudes on the y-axis. (not related to the pks but just next to them)

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

답변 (1개)

Rik
Rik 2020년 12월 5일

0 개 추천

Index your variable:
point(1:5)

댓글 수: 5

Fadi Lama
Fadi Lama 2020년 12월 5일
I don't know how to explain but point(1) is basically a peak so pks(1). I want to include the 5 proceding points which are basically magnitudes on the y-axis. (not related to the pks but just next to them)
Fadi Lama
Fadi Lama 2020년 12월 5일
pks(1:5) will give me values for other peaks
Rik
Rik 2020년 12월 5일
Doesn't the peaks function also return the indices?
Fadi Lama
Fadi Lama 2020년 12월 5일
I used the findpeaks function to find the 5 peaks of my graph. In my workspace pks is saved as a 5x1 matrix showing the 5 (y-axis) peaks
Rik
Rik 2020년 12월 5일
The findpeaks function has a second output. Did you read the documentation? That second output is what you need to use.
Try it. If you don't manage to find a solution, please post the code you used so I can edit that instead of writing it from scratch.

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

카테고리

질문:

2020년 12월 5일

댓글:

Rik
2020년 12월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by