Using interp1 to write code

1 visualizzazione (ultimi 30 giorni)
Jonathan Wehner
Jonathan Wehner il 7 Apr 2022
Modificato: Stephen23 il 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

Risposte (1)

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

Categorie

Scopri di più su Interpolation in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by