What does this code mean?
Show older comments
clc
t=linspace(-1,1,256);%%%
F=1; %%% kare dalga frekansı
A=2; %%% kare dalga genliği
harmonik=3;
kare=zeros(1,length(t));
for k=1:harmonik
coeff=(2*A)/(k*pi)*sin(k*pi/2);
kare=coeff*cos(k*2*pi*F*t)+kare;
end k_d=A/2+kare;
figure(1)
plot(t,kare);
grid on
close all
time=20;
Ts=1/100; %%% örnekleme frekansı
t=0:Ts:(time-Ts);
x=2*[t <= 2]; %%%% kare dalga genliği ve zaman aralığı
N=length(x);
ssf=((-N/2):(N/2-1))/(Ts*N);
fx=Ts*fft(x(1:N));
fxs=fftshift(fx);
figure
subplot(2,1,1);
set(plot(t,x),'LineWidth',1.5);
xlabel('sn');
subplot(2,1,2);
set(plot(ssf,abs(fxs)),'LineWidth',1.5);
xlabel('Frekans [Hz]'); ylabel('Genlik')
What does this code do? I need only variables like fx, ssf etc. What are these for?
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements 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!