Square wave with values 0 to 1 rather than -1 to 1
Mostra commenti meno recenti
Hi,
I know that the square(t) function produces a wave with an amplitude from -1 to 1, is it possible to produce it from 0 to 1 instead?
Thanks
1 Commento
Md Maidul Islam
il 27 Feb 2019
Modificato: Md Maidul Islam
il 30 Apr 2019
t=0:0.1:10;
x=0.5*(square(t)+1);
plot(t,x)
Risposte (2)
madhan ravi
il 5 Dic 2018
t = linspace(0,1).';
x = square(t);
Anamitra Datta
il 10 Apr 2021
0 voti
The above answers are wrong. It should be:
Assuming your period is 2*pi
x = 0.5*square(t)+0.5
This produces a square wave of 1 to 0 though in a cycle
If you need 0 to 1 in a cycle, you should do:
x = 0.5*square(t-pi)+0.5
Categorie
Scopri di più su Creating and Concatenating Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!