2016-03-15 26 views
0

我有一個實驗測量,看起來像一個正弦曲線,使得該函數可以建模爲sin(x)。如果我將asin函數應用於數據,我會得到一個三角函數。我想知道是否有一種形式可以像解開包裝一樣獲得與x相對應的直線。 任何意見將不勝感激。在matlab中恢復正弦函數的參數

回答

1

unwrap只適用於鋸齒模式,功能跳轉。所以我的想法是從你的功能創建這樣一個鋸齒圖案,然後應用解包。

%example function 
x=0:.1:10; 
y=sin(x); 
%invert 
x1=asin(y); 
%detect rising and falling 
s=[true,diff(x1)>0]; 
%continue falling segments rising, using the negative slope 
x2=x1.*s+(pi-x1).*(1-s); 
%finally use unwrap 
x3=unwrap(x2); 

%code for the plot 
%plot(x,y,x,x1,x,s,x,x2) 
%legend({'y','x1','s','x2'}) 

enter image description here

+0

真棒!非常感謝您 –

+1

@CarolinaRickenstorff考慮接受的答案,如果它滿足您的需求(這同樣適用於你以前的問題) –