fourierseries.m

来自「Program to plot x(t) =1/2+∑_(n=1)^∞&#96」· M 代码 · 共 32 行

M
32
字号
clc;clear all;
i=1;

in=str2num(input('What is the n-limit: ','s'));

for t=-4:0.1:4
    v(i)=0.5;
    w(i)=t;
    for n=1:1:in        
        v(i)=v(i)+[sinc(n/2)*cos(2*pi*n*t/4)];
        %plot(t,v(i),'bo')
        %hold on        
    end       
        i=i+1;  
end

plot(w,v,'k')

text(-0.8, max(v)/2, sprintf('Value of n is %d',in));
%text(0,max(v),' \leftarrow Simulated Graph','FontSize',10)
%gtext('ATAUR RAHMAN')
hold on

squarewave1(in) %Original Graph
legend('Simulated Plot','Original Plot');
title('Understanding Sinusoidal Signal and Harmonics')
xlabel('Time - Plot')
ylabel('X(n) - Plot')
hold on
%grid on

%stem(w,v,'o')

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?