MATLAB: Four element Array from workspace and plot it

arrayplotworkspace

I have a matrix a=[1 2 3 4] in my workspace, how can i plot it in the format a[x1 y1 x2 y2]. So that (x1y1) and (x1y2) forms a line.

Best Answer

plot(a(1:2:end), a(2:2:end))
is one way to do it.
But what you should do really is reshape a in x and and y rows:
a = reshape(a, 2, []);
plot(a(:, 1), a(:, 2));