間隔と長さの異なるベクトルに依存する値の誤差を計算したい
10 views (last 30 days)
Show older comments
二つの二次元配列の誤差を計算したいです。
二つの配列はそれぞれ時間tに依存する値 y1(t), y2(t)
なのですが、時間は不規則な増分かつ、y1とy2はそれぞれ異なる時刻に記録されたものです。
同じ時刻でy1とy2の誤差を計算するには
どちらかの計測時刻に合わせて線形補間して、、と考えたのですがうまくいきません。
以下、モデルのコードです。よろしくお願い致します。
t1 = sort(rand(1,20)).*10; t2 = sort(rand(1,15)).*10;
y1 = sin(t1); y2 = cos(t2);
figure(1)
plot(t1,y1,'or-',t2,y2,'ob-');
0 Comments
Answers (1)
Shunichi Kusano
on 7 Oct 2019
1次元信号の内挿でしたらinterp1で行えます。
下のサンプルはsin波を異なる時間でサンプリングしたときの例となります。
t1 = sort(rand(1,20)).*2*pi;
t2 = sort(rand(1,15)).*2*pi;
y1 = sin(t1);
y2 = sin(t2);
figure
plot(t1,y1,'or-',t2,y2,'ob-');
title('original simulated data');
legend('y1', 'y2');
y1_ = interp1(t1, y1, t2);
figure;
plot(t2, y1_, 'or-', t2, y2, 'ob-')
title('resampled result')
legend('resampled y1 at t2', 'y2')
0 Comments
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!