필터 지우기
필터 지우기

Issue with Fourier Series Stair Step Function

조회 수: 2 (최근 30일)
OvercookedRamen
OvercookedRamen 2022년 1월 29일
댓글: OvercookedRamen 2022년 1월 31일
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

채택된 답변

VBBV
VBBV 2022년 1월 30일
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
  댓글 수: 1
OvercookedRamen
OvercookedRamen 2022년 1월 31일
I got it to work, sort of. This is what I meant as a stair step function. Except it should be even.
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) + 1) * exp((-1j*pi)/2);
An = (-1/(2j*pi*i)) * ((exp((-2j*pi*i)/3)-1)) - ((-1/(1j*pi*i))) * (exp((-4j*pi*i)/3) - exp((-2j*pi*i)/3));
An_Conj = conj(An);
ff = ff + An * exp((2j*pi*i*t)/3) + An_Conj *exp((-2j*pi*i*t)/3);
end
end

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Physics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by