こんにちは、
測定データを三角関数 Ksin(ax+b)+c 関数に当てはめるのに苦労しています。これは私のプロセスの性質であり、JSLコードでそれを自動的に適合させる方法を探しています。
振動が -1 と 1 の間になるようにデータを正規化するコードを書きました。
最後に、a と b の定数を取得したいと思います (K と c も同様ですが、それははるかに簡単です)
私のデータ型の例を添付します。
BR、
ヨアヴ
を使用できますゼロクロス検出器これは、データを調べて、データが負から正に変化するたびに注目するためのちょっとした JSL です。 これが正弦波サイクルの始まりです。 次のゼロクロッシングまでの距離が周期です。
ノイズの多いデータが複数回交差するように見える場合、問題が発生する可能性があります。
ゼロクロスはピークよりも検出しやすいです。
そのアイデアを使用したのは、グリッチ。
こんにちは。お時間を割いていただきありがとうございます。 これは私のアプリケーションにとって素晴らしいアプローチのように思えます。しかし、どのようにして期間の長さを「自動的に」取得したのでしょうか? それはわかりませんでした。
ヨアヴ
素晴らしい、それはまさに私に欠けていた直感です。代わりに、グラフがデータに近づくまで非線形プラットフォームでパラメーター値を操作しましたが、パラメーターが何を表すかを知ること (およびデータから適切な初期推測を得る) は、はるかに優れた方法です。
私が正弦関数の標準形式と呼ぶもの、Y = K*sin(A*(x -
) + C を使用すると役立つと思います。
データ内:
K = 値の範囲の 1/2
A = 2*pi / 周期
B = 0 から正弦波の開始点まで右にシフト
C = Y 値の平均
非線形回帰の開始推定値は、ディストリビューション プラットフォームとグラフ ビルダーからの次の定義を使用して見つけることができます。
K = 1/2 * (最大 - 最小) = 1/2 * (47 - 17.6) = 14.7
A = 2 * 3.14 / 880 = 0.007
B = 662
C = 34.1


ノンリネアr退行このアプローチを使用すると、イオンは非常に早く収束します。モデルは、これらの値を使用した 5 回の反復で収束しました。 以下を参照してください

見積もりの取り方はこちらあるFFT関数を使用してパラメータを設定します。 秒と時間に関するコメントは、データが約 1 時間にわたって約 4 秒ごとに収集されたことを前提としています。 FFT は単位を気にしません。 FFT は、DC オフセット ビンの後の最初のビンが入力データの 1 つの完全なサイクルを構成できる最低周波数を表し、次のビンが 2 つの完全なサイクルになるようにデータの周波数をビン化します。...中央のビンは ndata/ 2サイクル。 以降のビンは最初のビンのミラーです。
dt = Open( "z:\example data.jmp" );
// by hand, I made a formula column to look at x-lag(x) and
// decided the first 79 and last 8 were not representative...
rowstart = 80;
rowstop = 937;
timeStart = dt:x[rowstart];
timeStop = dt:x[rowstop];
ydata = dt[rowstart :: rowstop, {y}]; // throw away a few with irregular time
{r, i} = FFT( {ydata} );
nBins = N Items( r );
sampleRate = (timeStop - timeStart) / (nBins - 1); // imagine there were only 2 bins...thus -1.
// the samplerate is ~4 seconds/sample...
// the highest frequency this can resolve is 1 cycle/ 8 seconds. (.125 Hz)
// frequencies higher than that will cause aliasing unless they are filtered out before this.
// the bin [nBins/2] represents the maximum frequency that can be resolved
lastBinFrequency = 1 / (2 * sampleRate); // ~ 0.125 Hz
// the first bin [1] is the DC, or offset from 0, component. We'll ignore it.
// the next bin [2] represents the frequency that has one cycle over the length of the data.
// the lowest non-DC frequency is one cycle per hour (the length of time the data was collected).
binWidth = 1 / (timeStop - timeStart); // ~0.0003Hz, or ~1 cycle per hour
// note: lastBinFrequency == (nbins-1)*binWidth/2 -- each bin is this wide, in frequency
// the remaining bins are a mirror of the first and ignored.
// combine real and imaginary bin components to get an amplitude
p = Sqrt( r ^ 2 + i ^ 2 );
dtGraph2 = As Table( ((rowstart :: rowstop) - rowstart)` || p );
dtGraph2 << Graph Builder(
Size( 1300, 500 ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Variables( X( :Col1 ), Y( :Col2 ) ),
Elements( Points( X, Y, Legend( 5 ) ) ),
SendToReport(
Dispatch( {}, "Col1", ScaleBox, {Format( "Best", 12 ), Min( 0 ), Max( nBins / 2 ), Inc( 100 ), Minor Ticks( 4 )} ),
Dispatch( {}, "Col2", ScaleBox, {Format( "Best", 12 ), Min( 0 ), Max( 30000 ), Inc( 5000 ), Minor Ticks( 1 )} ),
Dispatch( {}, "graph title", TextEditBox, {Set Text( "FFT Bins" )} ),
Dispatch( {}, "X title", TextEditBox, {Set Text( "bin number" )} ),
Dispatch( {}, "Y title", TextEditBox, {Set Text( "size" )} )
)
);
// there is a stong DC component in this data (all values > 0) so bin 1 is the max.
If( Loc Max( p ) != 1,
Throw( "something odd" )
);
p[1] = 0; // clear the DC value
// next max after DC:
maxBinIndex = Loc Max( p ); // 5. the data repeats about (5-1)==4 times in this frame.
Write(
"\!nBiggest frequency component at ",
binWidth * (maxBinIndex - 1),
" Hz or ",
Round( 1 / (binWidth * (maxBinIndex - 1)) ),
" seconds per cycle"
);
// where does a==.007 come from?
secondsPerCycle = 1 / (binWidth * (maxBinIndex - 1));
totalSeconds = timeStop-timeStart;
cyclesInSample = totalSeconds/secondsPerCycle;//about 4
timerange = timeStop-timeStart;
a_from_fft = cyclesInSample*2*pi()/timerange; // .0073...
show(a_from_fft);
One strong response in 4th bin after DC binOne strong response in 4th bin after DC binDC ビン後の 4 番目のビンに 1 つの強い応答
0.00116448326055313 Hz または 1 サイクルあたり 859 秒の最大周波数成分
a_from_fft = 0.007316664113164;
DC 成分はデータの平均に関連しており、 c価値。
これがあなたが望んでいることかどうかはわかりませんが、非線形プラットフォームを使用してこれを解決できます。データ、予測列 (パラメーターを使用して推定)、およびそれらのパラメーターを解決するスクリプトが添付されています。正直に言うと、解を収束させるためのパラメーターの最初の推測を得るまでにかなりの時間がかかったと思います (おそらく、sine 関数についての知識が足りなかったためです。このような関数を扱うのは本当に久しぶりです)。しかし、概念的には、非線形プラットフォームはあなたが望むことを実現します。