MATLAB: How to plot a square wave in Matlab functionMATLABmatlab function Hello As attached the square wave equation. How can I plot it ? Best Answer Try this: f = 5; % FrequencyN = 16; % Order Of Harmonicst = linspace(0, 4, 500); % Time Vectorsqwv = @(f,t,n) 4*sum(bsxfun(@rdivide, sin(2*pi*(1:2:N)'*t), (1:2:N)'))/pi;figureplot(t, sqwv(f,t,N))grid Related SolutionsMATLAB: Square wave RESOLUTION = 1000; %whatever is appropriateDUTYCYCLE = 0.73; %e.g. 73% on, 27% offNUMBEROFCYCLES = 18; %as appropriatebasepulse = ones(1,RESOLUTION);squarepulse = basepulse;squarepulse(floor(DUTYCYCLE * RESOLUTION) + 1 : end) = 0;wavetrain = repmat(squarepulse, 1, NUMBEROFCYCLES); MATLAB: Amplitude of square wave What I have seen that, you b is look like as following-A=2; f=3;t=0:.01:10;a=A*sin(2*pi*f*t);%figure, plot(t,a);b=A*sin(2*pi*f*t) + A*sin(3*2*pi*f*t)/3+A*sin(5*2*pi*f*t)/5+A*sin(7*2*pi*f*t)/7;%[pks,locs]=findpeaks(b);%findpeaks(b)plot(t,b);Why donot go for peak analysis? Visit here and read here Related QuestionConstruct a square wave
Best Answer