フィルターのクリア

how to get 10 plots of sine waves with frequencies f1:f10 using for loop

5 ビュー (過去 30 日間)
anam zahra
anam zahra 2017 年 9 月 14 日
編集済み: Stephen23 2017 年 9 月 15 日
fs=100;
t=0:1/fs:1;
f=[2 4];
Y=[];
for i=1:2
y=sin(2*pi*f(i)*t);
Y = [Y y];
figure
plot(t,Y)
end
  1 件のコメント
Stephen23
Stephen23 2017 年 9 月 14 日
編集済み: Stephen23 2017 年 9 月 15 日
@ anam Zahra: your code is very badly aligned. Badly aligned code is how beginners hide errors in their code. You should keep your code aligned, best would be to use the default MATLAB alignment. You can adjust the alignment automatically in the MATLAB editor by selecting all of the code and then pressing ctrl+i.

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

採用された回答

KSSV
KSSV 2017 年 9 月 14 日
fs=100;
t=0:1/fs:1;
f=[2 4];
y = zeros(length(f),length(t)) ;
for i=1:2
y(i,:)=sin(2*pi*f(i)*t);
end
plot(t,y)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by