Using interp1 to write code

3 views (last 30 days)
Jonathan Wehner
Jonathan Wehner on 7 Apr 2022
Edited: Stephen23 on 7 Apr 2022
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

Answers (1)

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

Categories

Find more on Interpolation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!