フィルターのクリア

Save the output of a for loop

2 ビュー (過去 30 日間)
marwa mohamed
marwa mohamed 2020 年 9 月 10 日
コメント済み: Ameer Hamza 2020 年 9 月 14 日
Hey!
i am trying to generate 3 sine waves with different frequenceies using a for loop. I would like to save the output of this for loop in a matrix 500x3, but it is always overwrite the previous value. can anyone help?
  1 件のコメント
KSSV
KSSV 2020 年 9 月 10 日
Show us the code....so that we can help you.

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

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 9 月 10 日
See this example
f = [1 2 3]; % frequencies
t = linspace(0, 10, 500); % time values
S = zeros(numel(t), 3); % array for storing signal values
for i = 1:numel(t)
s1 = sin(f(1)*t(i));
s2 = sin(f(2)*t(i));
s3 = sin(f(3)*t(i));
S(i, :) = [s1 s2 s3];
end
plot(S)
  2 件のコメント
marwa mohamed
marwa mohamed 2020 年 9 月 14 日
Thank you sooo much, that works
Ameer Hamza
Ameer Hamza 2020 年 9 月 14 日
I am glad to be of help!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by