Plotting graph using arrays

22 次查看(过去 30 天)
Shantanu Vachhani
Shantanu Vachhani 2017-10-25
x=zeros(1,10);
x(2:4) =1;
y= linspace(0,10,10);
plot(y,x)
I want a straight vertical line but matlab is giving me a slant line.Any solution?

回答(1 个)

KSSV
KSSV 2017-10-25
x = [1 1 2 3 4 4 5 6 7 8 9 10] ;
y = [0 1 1 1 1 0 0 0 0 0 0 0] ;
plot(x,y)

类别

Help CenterFile Exchange 中查找有关 Graph and Network Algorithms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by