I want to build the square wave: build a 6 subplot figure to show the time domain, and use respectively 1, 3, 5, 10, 50, 500 frequencies.How can i achieve this?

1 回表示 (過去 30 日間)
I want to build the square wave: build a 6 subplot figure to show the time domain, and use respectively 1, 3, 5, 10, 50, 500 frequencies.How can i achieve this?

採用された回答

Image Analyst
Image Analyst 2022 年 11 月 22 日
編集済み: Image Analyst 2022 年 11 月 22 日
Start with this:
allFreqs = [1, 3, 5, 10, 50, 500];
for k = 1 : length(allFreqs)
thisFreq = allFreqs(k);
subplot(length(allFreqs), 1, k);
% Code to generate Rect want, for you to do.
rectWave = whatever....................
plot(rectWave, 'b-', 'LineWidth', 2);
grid on
caption = sprintf('Frequency = %d', thisFreq);
title(caption, 'FontSize', 15);
drawnow;
end
  3 件のコメント
Image Analyst
Image Analyst 2022 年 11 月 22 日
I could but since it seems like your homework I don't want to get you into trouble by having you turn in my code as your own. I don't want you to get expelled! Try square function in the Signal Processing Toolbox.
Boyi
Boyi 2022 年 11 月 22 日
yep I understand .because it is my first time using Matlab, I am very unfamiliar with how to use it, but thank you for your reply, it was very helpful.

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

その他の回答 (1 件)

John D'Errico
John D'Errico 2022 年 11 月 22 日
Solve a problem that is too large for you to handle by breaking it up into small enough chunks to handle.
  1. Do you know how to use subplot? Clearly, you know about subplots. So read the help. Look at the examples.
  2. Do you know how to plot a square wave? It sounds like you are asking how to use an FFT, So learn how to use an FFT to solve the problem for one case, then using a loop, solve it 6 times.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by