why my last element in the array isn't being plotted ?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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
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 ...
Antworten (1)
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);

0 Kommentare
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!