How do I make this square wave graph?
4 ビュー (過去 30 日間)
古いコメントを表示
採用された回答
Adam Danz
2021 年 4 月 8 日
編集済み: Adam Danz
2021 年 4 月 8 日
Set the parameters at the top.
% Parameters
period = 2*pi; % Period
xrange = [0, 6*pi]; % [start,end] x values
amplitude = 2; % peak-trough amplitude
verticalShift = 0; % Vertical shift, negative shifts downward
phaseShift = 0; % Phase shift, negative shifts rightward
% create step fcn
th = linspace(xrange(1), xrange(2), 1000);
y = amplitude*(sin(2*pi/period*th+phaseShift)>0)-amplitude/2+verticalShift;
% Plot it
plot(th, y)
ylim([-2,2])
grid on
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Electrical Block Libraries についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!