extracting values at set intervals from a vector

From the following vector:
depth = [0:0.1:20];
How could I create a new vector that had the same data as 'depth' but a value taken every 0.5, providing an outcome of:
d2 = depth(1:5:end);
Since my data is not actually spaced at 0.1 intervals but at randomly distributed intervals I cannot apply the simple approach shown above. What would be the best methods of achieving this?

답변 (1개)

Jan
Jan 2012년 11월 6일

0 개 추천

Use interp1 for a linear interpolation.

댓글 수: 1

Richard
Richard 2012년 11월 6일
편집: Richard 2012년 11월 6일
Is there another way o doing this, the overall aim of what I am attempting to achieve is to measure the uncertainty of interpolation methods. Isn't there a method for taking the first value and then every value in the vector which is + 0.5 of the last? maybe use floor if they are not exact?

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

카테고리

도움말 센터File Exchange에서 Interpolation에 대해 자세히 알아보기

태그

질문:

2012년 11월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by