Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

lab 4 / test_extrap

.m
Скачиваний:
12
Добавлен:
19.04.2021
Размер:
867 б
Скачать
function test_extrap(x,y)
p=-x(2):0.1:1.5*x(end);
f1=interp1(x,y,p,'linear','extrap');
f2=interp1(x,y,p,'pchip','extrap');
f3=interp1(x,y,p,'next','extrap');
f4=interp1(x,y,p,'makima','extrap');
f5=interp1(x,y,p,'pchip',y(end));
f6=interp1(x,y,p,'makima',y(1));
for i=1:lenght(p)
f7=interp1(x,y,p,'spline');
if (p(i)<x(1))
f7=interp1(x,y,p,'spline',y(1));
end
if (p(i)>x(end)) %problems here
f7=interp1(x,y,p,'spline',y(end));
end %if
end %00for
figure;
hold on
plot(x,y,'ro')
plot(p,f1,p,f2,p,f3,p,f4,p,f5,p,f6,p,f7)
xline(x(1),'--',{'start of table points'})
xline(x(end),'--',{'end of table points'})
grid on
title('Exptrapolation Of the Table data y(x)');
xlabel('x');
ylabel('interp.function and table data');
legend({'y', 'linear','pchip','next','makima','makima-const','spline-const'},'location','best');
end %function
Соседние файлы в папке lab 4