can i know the way to code the square wave in Matlab?

조회 수: 1 (최근 30일)
NURRUZAINI MOHD NASIR
NURRUZAINI MOHD NASIR 2016년 5월 22일
편집: Azzi Abdelmalek 2016년 5월 23일
can i know the way to code the square wave in Matlab? the square wave that i need to solve just like in the picture

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 5월 22일
t=0:0.01:20;
y=square(t,50),
plot(t,y)
  댓글 수: 2
NURRUZAINI MOHD NASIR
NURRUZAINI MOHD NASIR 2016년 5월 23일
편집: Azzi Abdelmalek 2016년 5월 23일
by the way i already use this but some error occured... here i attached the appendix that i use
function [a0, a, b] = FourierSeries(f, T, N)
% symbolically calculate the Fourier Series, and return the numerical results
% f: the time domain signal within one period;
% it must have definition over 0<=t<=T
% it must be a symbolic function of t
% T: the period of the signal
% N: number of harmonics to be calculated
syms t % Time t
w0 = 2*pi/T; % Fundamental frequency w0
%%Calculate theFourier series coefficients
a0_sym = 1/T*int(f, t, 0, T); % Calculate a0
a0 = double(a0_sym); % Numerical values of a0
for n = 1:N
a_sym(n) = 2/T*int(f*cos(n*w0*t), t, 0, T); % Calculate an
b_sym(n) = 2/T*int(f*sin(n*w0*t), t, 0, T); % Calculate bn
a(n) = double(a_sym(n)); % Numerical values of an
b(n) = double(b_sym(n)); % Numerical values of bn
end

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Hilbert and Walsh-Hadamard Transforms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by