How should I accomplish this plotting task task in Matlab?
Thank you.
EDIT: What I am asking is how to plot in Matlab when the data are in one column as described in the link given above.
Regards,
ikel
How should I accomplish this plotting task task in Matlab?
Thank you.
EDIT: What I am asking is how to plot in Matlab when the data are in one column as described in the link given above.
Regards,
ikel
You could reshape
and transpose the matrix and extract the columns:
vec = [1 2 3 4 5 6 7 8 9 10 11 12]';
reshaped_mat = reshape(vec,3,[])';
reshaped_mat
will end up looking like this:
1 2 3
4 5 6
7 8 9
10 11 12
And you can extract the columns as follows:
x = reshaped_mat(:,1);
y = reshaped_mat(:,2);
z = reshaped_mat(:,3);
You can try something like this >
For example : A=[1 2 3; 4 5 6;7 8 9]
A'
would be
1 4 7
2 5 8
3 6 9
First take the transpose,
B = A'
And convert it into a single column,
B(:)
would give
ans =
1
2
3
4
5
6
7
8
9
Hope it helps
yet another option for the lazy user: given a vector v
v = [1 2 3 4 5 6 7 8 9 10 11 12];
since we know the elements go like [x1,y1,z1,x2,y2,z2,...]
, plotting x,y,z
will probably require plot3
, so this is how it can be done directly:
plot3(v(1:3:end),v(2:3:end),v(3:3:end))
where the entries are equivalent to
x=v(1:3:end);
y=v(2:3:end);
z=v(3:3:end);