필터 지우기
필터 지우기

generate vector from fixed point

조회 수: 1 (최근 30일)
matteo avanzi
matteo avanzi 2017년 11월 30일
답변: Jos (10584) 2017년 11월 30일
I have a 1x35 array, i want to generate a vector 1x31822 interpolating from the 35 points of the first vector, in a way that the two vectors could have the same shape.
which is the best method?
thanks
  댓글 수: 2
Jos (10584)
Jos (10584) 2017년 11월 30일
what do you mean by "have the same shape"? Can you give a small example?
matteo avanzi
matteo avanzi 2017년 11월 30일
yes, the first array represent a kind of parabola with 35 points, i want to create a vector using this 35 points as keypoints; for example between the 1st and 2nd there must be around 909 points(31822/35) that interpolate the 1st and 2nd points. and so on for every point.
hope that it's better
thanks

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

채택된 답변

KSSV
KSSV 2017년 11월 30일
Read about interp1.
th = linspace(0,2*pi,35) ;
y = sin(th) ;
figure
hold on
plot(th,y,'.r')
%%interpolation
thi = linspace(min(th),max(th),31822) ;
yi = interp1(th,y,thi) ;
plot(thi,yi,'b') ;

추가 답변 (1개)

Jos (10584)
Jos (10584) 2017년 11월 30일
interp1 is your friend. An example:
x = [0 4 7 10]
y = (x-5).^2
xx = linspace(0,10,13)
yy0 = interp1(x,y,xx) % default: linear interpolation
yy1 = interp1(x,y,xx,'pchip')
plot(xx,yy0,'r-',xx,yy1,'g-', x,y,'bo')

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by