2013-12-07 46 views
0

這些是機翼形狀的一些數據點:平滑機翼數據

x=[1 0.8518 0.7040 0.5536 0.3988 0.2454 0.0937 0.0199 0.0015 0 0.0169 0.0812 0.2054 0.3525 0.4979 0.6457 0.7974 0.9497]; 
y=[0 0.0355 0.0819 0.1206 0.1347 0.1200 0.0777 0.0363 0.0162 0 -0.0197 -0.0428 -0.0645 -0.0749 -0.0701 -0.0506 -0.0249 -0.0026]; 

我不能使用任何曲線擬合工具箱。我可以用什麼方法繪製出更平滑的翼型形狀。我應該使用polyfit還是interp1?

回答

1

是,interp1應該做的工作,但你需要灑你的數據在兩半,正y和負y,及其相應的x值。

這是一個使用三次插值的例子。檢查doc for interp1瞭解更多詳情:

ypos = y(y>=0); % y only when positive 
xpos = x(y>=0); % corresponding values of x 
yneg = y(y<0);  % y only when strictly negative 
xneg = x(y<0);  % corresponding values of x 
xi=linspace(0,max(x),100);      % values of x for interpolation (100 values linearly spaced between 0 and the max of x 
yposi = interp1(xpos,ypos,xi,'cubic','extrap'); % interpolated values of y (when positive) using cubic interpolation and extrapolation 
ynegi = interp1(xneg,yneg,xi,'cubic','extrap'); % interpolated values of y (when strictly negative) using cubic interpolation and extrapolation 
plot(x,y,'ro',xi,yposi,'b-',xi,ynegi,'b-')  % plot interpolated data on top of original data