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 Center および File ExchangeLog Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by