why my last element in the array isn't being plotted ?

9 ビュー (過去 30 日間)
ahmed abdelmgeed
ahmed abdelmgeed 2019 年 12 月 25 日
回答済み: Image Analyst 2019 年 12 月 25 日
i am plotting this arra using stairs function, but when I plot it doesnt plot the last element in the array
x=([0 1 1 0 1])
figure(1)
z=stairs(0:length(x)-1,x)
%plot(x)
ylim([-0.2 1.2]);
  1 件のコメント
dpb
dpb 2019 年 12 月 25 日
It does, it's just occluded by the RH axis
xl=xlim; % retrieve x limits
xlim([xl(1) 1.05*xl(2)]) % increase RH a little
Or, you could increase the linewidth property to make the line bold enough to stand out or change colors or ...

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2019 年 12 月 25 日
Try this improved code:
yValues = ([0 1 1 0 1])
xValues = 0 : length(yValues) - 1;
z = stairs(xValues, yValues, 'LineWidth', 3)
grid on;
ylim([-0.2 1.2]);
xlim([0, 5]);
xlabel('X', 'FontSize', 15);
ylabel('Z', 'FontSize', 15);
title('Z vs. X', 'FontSize', 15);
0000 Screenshot.png

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by