2017-12-13 16 views
-1

最新のクエリで正しく説明できないまま残っていると思うので、アップグレードされたより集中したバージョンのクエリを求めています。新しいタイムアレイを使用したオーディオ信号のリサンプリング

私はdown sample私の信号は、新しい時間配列に基づいてします。

time arraysample arrayです。

t = [0 2 3 7 8 9 10 11 12 17 18 19 20]; 

A = [0 0 1 2 3 5.2 0 -1.4 0 2 2.7 2 2.3]; 

新しい時間列は次のとおりです。

Tx = 1:4:25; 

私はstackoverflowの上アンドレイ・ダビドフが提案した補間を使用していますが、私は、私は、障害時にいくつかのポイントだと思います。

私はどこにいるのですか?ありがとうございます。

もしTの値がw.r.t(t)と同じなら、その値を使用し、値が見つからない場合は値を補間し、その値を新しい時刻に割り当てます。

コード例:私の前の質問へ

t = [0 2 3 7 8 9 10 11 12 17 18 19 20 ]; 
A = [0 0 1 2 3 5.2 0 -1.4 0 2 2.7 2 2.3 ]; 
plot(t,A) 
Tx = 1:4:25; 
B = interp1(t,A,Tx); %re-make example data to have decimal points on the x-axis 
y = resample(B, 1, 2); 
T = 0.05; 
Ty = T/(1/2); 
ty = (0:length(y)-1)*Ty; 
figure 
plot(Tx,B,'b') 
hold on 
plot(ty,y,'r') 
plot(t,A,'g') 
hold off 

リンクをここに装着されています。

Resampling of time signal in MATLAB

注:

これは私がこれをより明確かつ成熟して欲しい、まさに今です。

私はMATLABバージョン2012bを使用していますので、2012bで動作しないMatlabビルドコマンドが少ないため、解決策を提供してください。

答えて

1

メインあなたの問題 - あなたは元の時間が20で終了として、推定するためにしようとしたが、ユアーズは、このコードを試してみてください25.で終了:

clc 
t = [0 2 3 7 8 9 10 11 12 17 18 19 20 ]; 
A = [0 0 1 2 3 5.2 0 -1.4 0 2 2.7 2 2.3 ]; 

Tx = 1:4:25; % Are you sure you want to extrapolate? 
       % max(Tx1)>max(t) 

% This variant is WITHOUT extrapolation 
B = interp1(t,A,Tx); 
% This variant is WITH extrapolation and WHOLE time-series interpolated 
% cubically 
extrapBcub=interp1(t,A,Tx,'pcchip'); 
% If you want to have linear (default) interpolation, but cubic 
% extrapolation then 
extrapBlin=[B(~isnan(B)), extrapBcub(isnan(B))]; 

それは、次の図与える:

f=figure('Position',[50 50 1500 800]) 
h1=subplot(1,2,1); 
hold all 
h(1)=plot(t,A,'-ok','LineWidth',3) 
h(2)=plot(Tx,B,'-ob','LineWidth',9) 
h(3)=plot(Tx,extrapBcub,':or','LineWidth',7) 
h(4)=plot(Tx,extrapBlin,'-og','LineWidth',3) 
xlabel('time') 
ylabel('signal') 
set(gca,'Box','off','Color','none','FontSize',14,'LineWidth',2) 
legend({'Original data','No extrapolation','Cubic all',... 
    'Linear interpolation+cubic extrapolation'},'Location','SouthOutside',... 
    'FontSize',22) 
legend boxoff 
h2=subplot(1,2,2); 
hold all 
h3 = copyobj(h(end:-1:1), h2) % copy plots just for scaling 
ylim([-2 6]) 
xlabel('time') 
ylabel('signal') 
set(gca,'Box','off','Color','none','FontSize',14,'LineWidth',2) 

+0

ありがとうzlonそれはよく働いた。よいひとときを。 – john

関連する問題