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

1 Ansicht (letzte 30 Tage)
ahmed abdelmgeed
ahmed abdelmgeed am 25 Dez. 2019
Beantwortet: Image Analyst am 25 Dez. 2019
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 Kommentar
dpb
dpb am 25 Dez. 2019
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 ...

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 25 Dez. 2019
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

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by