I am trying to store data from each iteration into a vector. I cannot seem to figure it out as it will only store the value from the last iteration. I want every value that is above the threshold, which is inputed by the user, to be stored into its own vector.
load sound.dat
t = input('Please enter threshold value:');
n = length(sound);
%Calculations
for v = 1:1:n
if sound(v)>t
x = sound(v);
end
end
Thank you!

 採用された回答

David Hill
David Hill 2021 年 3 月 24 日

0 投票

load sound.dat
t = input('Please enter threshold value:');
n = length(sound);
x=sound(sound>t);

1 件のコメント

Joel Matias
Joel Matias 2021 年 3 月 24 日
I understand now! Thank you!

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

その他の回答 (0 件)

カテゴリ

製品

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by