Spline interpolation is giving me errors with array index
조회 수: 1 (최근 30일)
이전 댓글 표시
Here is my code:
t = linspace(0,2*pi,8)';
f = sin(t).^2 ;
xx = linspace(0,2*pi);
yy = spline(t,f,xx);
and
Here is the error it is giving me:
Index in position 1 is invalid. Array
indices must be positive integers or
logical values.
Error in (line 4)
yy = spline(t,f,xx);
댓글 수: 0
답변 (1개)
Akira Agata
2019년 4월 3일
At least the latest version R2019a, your code works well.
Anyway, I would recommend adjusting vector direction of t and xx, like:
t = linspace(0,2*pi,8)'; % Column vector
f = sin(t).^2 ;
xx = linspace(0,2*pi)'; % Column vector
yy = spline(t,f,xx);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Splines에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!