i have a binary data how can i plot the square wave for the binar data in matlab?
Show older comments
i have a binary data how can i plot the square wave and sawtooth wave for 0's and 1's in matlab?
1 Comment
Azzi Abdelmalek
on 16 Sep 2013
How your 0 and 1 are disposed ?
Answers (1)
Azzi Abdelmalek
on 16 Sep 2013
%----------------your signal y - and time x-------------
n=10
y=repmat([1 0],1,n)
y=y(:)
x=1:n
%--------------sawtooth---------------------
x=[x;x]
x=x(:)
close
plot(x,y,'r')
%---------square-------------
figure
y=[y';y']
y=y(:)
x=1:numel(y)/2;
x=[x;x];
x=x(:)
x(1)=[];
y(end)=[]
plot(x,y,'r')
xlim([x(1) x(end)])
Categories
Find more on Contour Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!