Using interp1 to write code

1 次查看(过去 30 天)
Jonathan Wehner
Jonathan Wehner 2022-4-7
编辑: Stephen23 2022-4-7
I am trying to complete steps 3-6 here. This is the code I have but all the graphs keep turning out the same...
clc
clear
HbData=dlmread('HbSpectra.txt');
IV = HbData(:,1);
FDV = HbData(:,2);
FM = 'o';
semilogy(IV, FDV, FM)
hold on
SDV = HbData(:,3);
SM = '+';
semilogy(IV, SDV, SM)
hold off
TT = linspace(400,896);
vl = interp1(IV,FDV,TT);
figure;plot(IV,FDV,'o',TT,vl)
title('linear interpolation')
vl = interp1(IV,SDV,TT);
hold on
plot(IV,SDV,'+',TT,vl)
title('linear interpolation')
hold off
vs = interp1(IV,FDV,TT,'spline');
figure;plot(IV,FDV,'o',TT,vs)
title('spline interpolation')
vs = interp1(IV,SDV,TT,'spline');
hold on
plot(IV,SDV,'+',TT,vs)
title('spline interpolation')
hold off
vh = interp1 (IV,FDV,TT,'pchip');
figure;plot (IV,FDV,'o',TT,vh)
title('pchip interpolation')
vh = interp1 (IV,SDV,TT,'pchip');
hold on
plot (IV,SDV,'+',TT,vh)
title('pchip interpolation')
hold off

回答(1 个)

Star Strider
Star Strider 2022-4-7
It may only be possible to see the differences by subtracting them from each other or plotting them against each other.

类别

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