Issue with Fourier Series Stair Step Function
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
OvercookedRamen
el 29 de En. de 2022
Comentada: OvercookedRamen
el 31 de En. de 2022
I am supposed to be seeing a stair step function, but I get a striaght line instread. I am seeing this warning "Warning: Imaginary parts of complex X and/or Y arguments ignored ". What could be causing this?
Code:
n_count = 400;
t_count = [0:0.01:24];
y_count = Fourier_Function(n_count, t_count);
figure;
plot(t_count, y_count);
title("Stair Step Function for Problem 4");
xlabel("Time (s)");
ylabel("Signal Magnitude (v)");
function [ff] = Fourier_Function(n, t)
ff = 1; %Ao term acting as 1 and allowing sum functionality
for i = 1:1:n %Acting as our n vairable
An = (-1/(-2j*pi*i)).*((exp((-2j*pi*i)/3) - 2.*(exp((-4j*pi*i)/3)))).*exp((-j*pi)/2);
An_Conj = conj(An);
ff = ff + An.*exp((2j*pi*i*t)/3).* An_Conj .*exp((-2j*pi*i*t)/3);
end
end
0 comentarios
Respuesta aceptada
VBBV
el 30 de En. de 2022
n_count = 400;
t_count = [0:1:24];
y_count = Fourier_Function(n_count, t_count);
figure;
plot(t_count, abs(y_count),'-.');
title("Stair Step Function for Problem 4");
xlabel("Time (s)");
ylabel("Signal Magnitude (v)");
function [Ff] = Fourier_Function(n, t)
ff = 1; %Ao term acting as 1 and allowing sum functionality
for k = 1:length(t)
for i = 1:1:n %Acting as our n vairable
An = (-1/(-2j*pi*i)).*((exp((-2j*pi*i)/3) - 2.*(exp((-4j*pi*i)/3)))).*exp((-j*pi)/2);
An_Conj = conj(An);
ff = real(ff) + An.*exp((2j*pi*i*t(k))/3)+An_Conj .*exp((-2j*pi*i*t(k))/3);
end
Ff(k,:) = ff;
end
Ff;
end
Do you mean this ? functions needs to be modified
Más respuestas (0)
Ver también
Categorías
Más información sobre MATLAB Algorithm Acceleration en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!