reduce values on a vector

6 ビュー (過去 30 日間)
Miguel Albuquerque
Miguel Albuquerque 2022 年 7 月 5 日
編集済み: Jan 2022 年 7 月 6 日
Hey guys,
I have this code. This two signal have a lot of values(millions) I want to use 1000 values(reference_signal_samples and Surveillance_signal_samples) with a step of 3000 samples. Im not able to do it with this code, I dont know where the error is.
Thank you
nRef = numel(Reference_signal)/Fs;
nSurv = numel(Surveillance_signal)/Fs;
pulse_size = 1000;
for k = 1:nRef
Reference_signal_samples =Reference_signal((k-1)*pulse_size+(1:pulse_size));
for kk =1:nSurv
Surveillance_signal_samples=Surveillance_signal((kk-1)*pulse_size+(1:pulse_size));
end
end

採用された回答

Jan
Jan 2022 年 7 月 5 日
You are overwriting the variable Surveillance_signal_samples repeatedly:
for kk =1:nSurv
Surveillance_signal_samples=Surveillance_signal((kk-1)*pulse_size+(1:pulse_size));
end
You want to use 1000 values with a stepwidth of 3000?
Reference_signal_samples = Reference_signal(1:3000:3000*1000);
Surveillance_signal_samples = Surveillance_signal(1:3000:3000*1000);
No loops.
A hint: Use more compact names for variablkes to improve the readability.
  2 件のコメント
Miguel Albuquerque
Miguel Albuquerque 2022 年 7 月 5 日
編集済み: Miguel Albuquerque 2022 年 7 月 5 日
sorry, shoudnt it be?
And with that code, than I have to change the values, because next I want the iteration 4000 to 5000
I want first Reference_signal_samples(1:1000), plot the signals, next Reference_signal_samples(4000:5000), plot the signals, till the end of samples(millions)
Reference_signal_samples = Reference_signal(1:3000:3000);
Jan
Jan 2022 年 7 月 6 日
編集済み: Jan 2022 年 7 月 6 日
Maybe I've misunderstood your question.
disp(1:3000:3000)
1
1:3000:3000 is the scalar 1. If you really want to get parts of the array, these indices are strange: 1:1000, 4000:5000 : The 2nd has 1001 elements, the first only 1000. Maybe you mean:
for k = 1:4000:numel(Reference_signal)
signal = Reference_signal(k:k+999);
... here your calculations...
end

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by