Azzera filtri
Azzera filtri

サンプリング数の少ない場合のグラフ描画

4 visualizzazioni (ultimi 30 giorni)
Ochi Kai
Ochi Kai il 12 Ott 2022
Commentato: Ochi Kai il 13 Ott 2022
例えば変数
A = [0, 0, 40, 42, 40, 28, 20, 19, 23, 0, 0];
time = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
があり、Aは何かの信号、timeは時間として10秒分のデータを取得したとしています。
plot(time,A,'-r','LineWidth',1.2);
を実行するとグラフは表示できますが、サンプリング数が少ないため、かくかくしたグラフとなってしまいます。
B = smoothdata(A);
plot(time,B,'-o','LineWidth',1.2);grid on;
smoothdata関数等も使いましたが、あまりうまくいきません。何か良い方法はないでしょうか?
ご教授お願いいたします。

Risposta accettata

Hernia Baby
Hernia Baby il 12 Ott 2022
resampleもしくはinterp1を使用してください。
A = [0, 0, 40, 42, 40, 28, 20, 19, 23, 0, 0];
time = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
tq = linspace(0,10,1000);
B = interp1(time,A,tq,'spline');
plot(time,A,'ko','LineWidth',1.2);hold on;grid on;
plot(tq,B,':','LineWidth',1);
legend({'original','interp'})
  1 Commento
Ochi Kai
Ochi Kai il 13 Ott 2022
本当にありがとうございます。大変勉強になりました。

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Networks in Help Center e File Exchange

Tag

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!