i need to calculate the value of the cubic spline not a knot in the point x=1.97, the problem gives me coordinates of x=[0.0 0.5 1.0 1.5 2.0] and the function y=(sin(x)-(x+1).^2)/(x.^2+3). i don't understand why sometimes when i do y=f(x) it gives me a vector and sometimes like now it gives me only a value, and as a result it gives me an error when calculating the spline.

 채택된 답변

KSSV
KSSV 2018년 6월 20일

0 개 추천

x=[0.0 0.5 1.0 1.5 2.0] ;
y = @(x) (sin(x)-(x+1).^2)./(x.^2+3) ;
y = y(x) ;
xi = 1.97 ;
yi = interp1(x,y,xi,'spline')
plot(x,y,'b')
hold on
plot(xi,yi,'*r')

댓글 수: 2

Gianluca Manissero
Gianluca Manissero 2018년 6월 20일
thanks a lot, i didn't put the point before the "/" that's why i wasn't able of solving the exercise.
Kaloyan Pavlov
Kaloyan Pavlov 2020년 12월 8일
Sorry I dont understand, if you have the function why not just calculate the function with x = 1.97?

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

추가 답변 (0개)

카테고리

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

제품

릴리스

R2018a

태그

질문:

2018년 6월 20일

댓글:

2020년 12월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by