I'm trying to plot some Fourier Exponential Series but everytime I run my script nothing is comming out.
This is my script, any ideas on what am I doing wrong?
clc; close all; clear all;
%%Periodic Signal: Parameters
A = 6;
T = 10;
Co = 0;
%%Obtain distance between times
Wo = 2 * pi / T;
t0 = T;
tf = 1.5 * T;
dt = tf /500;
t = 0 : tf : dt;
%%Square wave aproximation
Vt = Co * ones (size (t));
for n = 0 : 1 : 100
Cn = (4 * A / n*pi) * sin(n * pi/2);
Vt = Vt + Cn * exp(1j * n * Wo * t);
plot(Vt, t),...
xlabel('Time (s)'),ylabel('V(t)'),...
title('Aproximation '),grid on,...
hold on;
end

 채택된 답변

VBBV
VBBV 2020년 11월 30일
편집: VBBV 2020년 12월 1일

0 개 추천

%rue
clc; close all; clear all;
%%Periodic Signal: Parameters
A = 6;
T = 10;
Co = 0;
%%Obtain distance between times
Wo = 2 * pi / T;
t0 = T;
tf = 1.5 * T;
dt = tf /500;
t = 0 : dt : tf; % time step is larger than vector, dt used as time step
%%Square wave aproximation
Vt = Co * ones (size (t));
for n = 1 : 1 : length(t)
Cn = (4 * A / n*pi) * sin(n * pi/2);
Vt(n) = Vt(n) + Cn * exp(1j * n * Wo*t(n));
plot(t(1:n),Vt(1:n)),...
xlabel('Time (s)'),ylabel('V(t)'),...
title('Aproximation '),grid on,...
hold on;
end

댓글 수: 3

VBBV
VBBV 2020년 11월 30일
Use for loop indexing for Velocity, Vt and time t
VBBV
VBBV 2020년 12월 1일
Alan Salgado
Alan Salgado 2020년 12월 1일
That was very helpful, thank you.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

제품

릴리스

R2020b

질문:

2020년 11월 30일

댓글:

2020년 12월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by