Borrar filtros
Borrar filtros

間隔と長さの異なるベ​クトルに依存する値の​誤差を計算したい

12 visualizaciones (últimos 30 días)
Masaki Maeda
Masaki Maeda el 7 de Oct. de 2019
Respondida: Shunichi Kusano el 7 de Oct. de 2019
二つの二次元配列の誤差を計算したいです。
二つの配列はそれぞれ時間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-');

Respuestas (1)

Shunichi Kusano
Shunichi Kusano el 7 de Oct. de 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')

Categorías

Más información sobre 内挿 en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!