Using interp1 to write code

1 Ansicht (letzte 30 Tage)
Jonathan Wehner
Jonathan Wehner am 7 Apr. 2022
Bearbeitet: Stephen23 am 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

Antworten (1)

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

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by