square wave not "limited"

7 ビュー (過去 30 日間)
Federico Paolucci
Federico Paolucci 2022 年 6 月 30 日
回答済み: Jon 2022 年 6 月 30 日
hi, I produced this square wave signal, but as you can see the square peaks have no upper limit. how can i solve?
x=0.03*square(f*t,duty)
in reality I seem to see that the graph is the other way around

採用された回答

Jon
Jon 2022 年 6 月 30 日
You probably are not correctly specifiying the duty cycle. If you want the square wave to be "on" half the time you should set duty = 50, also note that the first argument to square is in radians, so each cycle is 2*pi radians. You have to scale your input accordingly.

その他の回答 (1 件)

Sam Chak
Sam Chak 2022 年 6 月 30 日
Doesn't seem to have any issue.
t = linspace(0, 3*pi, 3001)';
f = 2;
duty = 50;
x = 0.03*square(f*t, duty);
plot(t/pi, x, t/pi, 0.03*sin(2*t))
grid on
ylim([-0.05 0.05])

カテゴリ

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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by