Put vectors with different length into NaN vectors with allways the same length

1 回表示 (過去 30 日間)
Lutz
Lutz 2023 年 1 月 11 日
コメント済み: Jiri Hajek 2023 年 1 月 16 日
Hey guys,
I have a lot of data vectors wich have a different length. I want to compare them, to do so i have to normalize them. To normalize they need to have the same length.... So i wrote a loop to put the data vectors into a NaN-vector which has allways the same length.
My Problem is that the loop need pretty long depending on the size of 44100 NaN positions:
clc
clear all
[x,Fs] = audioread("Lisa_Tones/Pü(1).wav")
Fs = 44100
V1 = NaN(Fs,1)
for i= 1:length(x)
V1(i,1) = x(i,1)
end
Is there an option to do that much faster ? Or is there another way to fill the data vectors with NaN so they have the same length?
Thank you!

採用された回答

Jiri Hajek
Jiri Hajek 2023 年 1 月 11 日
編集済み: Jiri Hajek 2023 年 1 月 11 日
Hi, the for loop is not required, you can achive the same assignment simply by:
V1(1:length(x),1) = x;
  2 件のコメント
Lutz
Lutz 2023 年 1 月 14 日
Thanks for showing me the Forest :D
Jiri Hajek
Jiri Hajek 2023 年 1 月 16 日
You are welcome!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAudio I/O and Waveform Generation についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by