Why is my plot blank? (New to MATLAB)

조회 수: 2 (최근 30일)
Daniel Spejcher
Daniel Spejcher 2019년 11월 22일
답변: Erivelton Gualter 2019년 11월 22일
for x = linspace(-pi,pi,.01)
S(x) = (2.*H(x))-1;
end
figure
plot(S(x),x,'-r*');
axis([-pi pi -3 3]);
title('S(x) vs. x');
xlabel('x');
ylabel('S(x)');
My assignment is dealing with the Fourier Series and the Heaviside Function and I am trying to plot S(x) vs. x but my plot is blank.

답변 (1개)

Erivelton Gualter
Erivelton Gualter 2019년 11월 22일
Try the following:
x = -pi:.1:pi;
for i=1:length(x)
S(i) = (2.*heaviside(x(i)))-1;
end
figure
plot(S,x,'-r*');
axis([-pi pi -3 3]);
title('S(x) vs. x');
xlabel('x');
ylabel('S(x)');

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by