Reputation: 213
The code that I wrote is :
figure
hold on
axis equal
axis([0 20 0 10])
for k = 1:9
plot([k(k+1) k(k+2)],[9 1])
end
What I tried doing is indexing but I am not sure if this is valid in for loops. I need help in xdata of the plot such that in first iteration the coordinates will be [k k+1] then in 2nd iteration, the coordinates will be [k+1 k+2], 3rd would be [k+2 k+3] and so on.
Upvotes: 0
Views: 46
Reputation: 13876
I think this is what you want:
figure
for k=1:9
plot([2*k-1 2*k],[9 1])
hold on
end
axis([0 20 0 10])
axis equal
Upvotes: 2