How to plot a square wave with specific conditions?
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I need to plot a square wave signal with ones and zeros; the wave must be a 0 when y is <5 and must be a 1 when y >5. The wave must be on the same graph as the y signal (shown below) Any help would be appreciated.
I have the following code as the initial conditions.
clear all
S = [6,4,6,5,0,3,1];
A = sum(S);
B = 2.5;
T = mean(S)/1000000;
f = 1/T;
fs = 100*f;
Ts = 1/fs;
phi = sum(S)*180/pi;
t = 0:Ts:5*T;
y = A*sin(((2*pi)/T)*t+ phi)+B;
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!