how to zero pad a vector to have the same amount of data as a vector with more data?
28 ビュー (過去 30 日間)
古いコメントを表示
I have read multiple other threads with questions similar to this, however none of these were able to work in my case.
quick description: i have two audio signals. the "verb" signal is longer than the "in" signal. I want to change the "in" signal to have the same amount of data (i.e, the length of verb = length of in), using zero padding.
Can someone please walk me through how to achieve this? I have tried many things. Here is the code that reads the inputs as well as my best attempt to zero pad the "in" signal.
thank you for your help
%%% goal: to have the length of 'in' equal the length of 'verb'
%%% define inputs
[in, fs] = audioread('smash_hit.wav'); % input signal defined
in = in(:,1); % converts signal to mono, if needed
[verb, ~] = audioread('warehouse.wav'); % reverb response signal defined
verb = verb(:,1); % converts signal to mono, if needed
in_padded = [in, zeros(1, length(verb))];
0 件のコメント
回答 (3 件)
Les Beckham
2023 年 11 月 13 日
Try this:
%%% goal: to have the length of 'in' equal the length of 'verb'
%%% define inputs
[in, fs] = audioread('smash_hit.wav'); % input signal defined
in = in(:,1); % converts signal to mono, if needed
[verb, ~] = audioread('warehouse.wav'); % reverb response signal defined
verb = verb(:,1); % converts signal to mono, if needed
% in_padded = [in, zeros(1, length(verb))];
in_padded = [in, zeros(1, length(verb) - length(in))]; % <<< corrected this line
参考
カテゴリ
Help Center および File Exchange で Measurements and Spatial Audio についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!