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