MATLAB: How to plot random ones and zeros as sequare wave plot bits i am trying to plot my random binary signal as square wave using these simple code s=rand(1,10)>0.5;t=1:1:10;plot(t,s); but its appear as triangle wave as shown below Best Answer n=20s=rand(1,n)>0.5;s=repmat(s',1,100)'s=s(:)'t=linspace(0,n,numel(s))plot(t,s,'r') Related SolutionsMATLAB: How we can change a Duty Cycle for a signal Do you have the Image Processing Toolbox, if so, just simply use imresize() to get the new pattern in the length that you want. Try this code:A = [1,1,0,1,0,1,0,1,1];newA = A; % Let's say the first cycle is the starting pattern.for cycle = 1 : 3 % Get a random length for this pattern between 9 and 30 newSize = length(A) + randi(21, 1) newPattern = imresize(A, [1,newSize], 'Nearest') newA = [newA, newPattern]end MATLAB: I am not quite sure how to create 5 random numbers between 0 and 10. s(1)=rngrandi([0 10],1,5)to get the same sequencerng(s(1))randi([0 10],1,5) Related QuestionHow to plot this figure?How to create a random matrix that contains only of 0’s, 0.5’s and 1’s
Best Answer