Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% Run me.
- close all; clc;
- T = 1;
- t = linspace(-T,T,1e5);
- N = 1;
- A0 = 0;
- A = zeros(1,N);
- B = zeros(1,N);
- x = A0*ones(size(t));
- for n = 1:N
- A(n) = 0;
- B(n) = ((-1)^(n+1))/(pi*n);
- x = x + A(n)*cos(2*pi/T*n*t) + B(n)*sin(2*pi/T*n*t);
- end
- N2 = 3;
- A2 = zeros(1,N2);
- B2 = zeros(1,N2);
- x2 = A0*ones(size(t));
- for n = 1:N2
- A2(n) = 0;
- B2(n) = ((-1)^(n+1))/(pi*n);
- x2 = x2 + A2(n)*cos(2*pi/T*n*t) + B2(n)*sin(2*pi/T*n*t);
- end
- N3 = 10;
- A3 = zeros(1,N3);
- B3 = zeros(1,N3);
- x3 = A0*ones(size(t));
- for n = 1:N3
- A3(n) = 0;
- B3(n) = ((-1)^(n+1))/(pi*n);
- x3 = x3 + A3(n)*cos(2*pi/T*n*t) + B3(n)*sin(2*pi/T*n*t);
- end
- x4 = A0*ones(size(t));
- x4 = sawtooth(2*pi*(t-0.5))/2;
- x5 = A0*ones(size(t));
- x5 = rms(x4-x);
- %% Plot me
- figure;
- plot(t,x4);
- hold on;
- %plot(t, x2);
- %plot(t, x3);
- %plot(t, x4);
- plot(t, x5);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement