Filter löschen
Filter löschen

How to plot binary sine function?

2 Ansichten (letzte 30 Tage)
NoYeah
NoYeah am 8 Apr. 2020
Kommentiert: NoYeah am 9 Apr. 2020
binary sine function change its amplitude to minus after a peirod
for example) T=3, Range 0~6
y=sin(t/3) for 0<=t<3
y=-sin(t/3) for 3<=t<6
it reculsively occurs for whole range
6~9, 15~18, ....
9~12, 18~21, ....
how to plot this graph?

Akzeptierte Antwort

Akira Agata
Akira Agata am 8 Apr. 2020
How about modulating a phase with 0 <-> pi ?
The following is an example:
T = 3;
time = linspace(0,T*4,1000);
% Create a phase 0 <-> pi
binary = mod(floor(time/3),2) == 1;
phi = pi*binary;
% Plot a phase modulated signal
figure
plot(time,sin(2*pi*(1/T)*time + phi))

Weitere Antworten (1)

David Hill
David Hill am 8 Apr. 2020
t=0:.01:30:
y=sin(2*pi*t/3).*(-1).^floor(t/3);%I think you are missing the 2*pi
plot(t,y);
  3 Kommentare
David Hill
David Hill am 8 Apr. 2020
It works fine for me, floor is never fractional.
NoYeah
NoYeah am 9 Apr. 2020
yes but if you set floor set fractional, the result may not correct

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by