- #1
gnurf
- 370
- 8
How to create a matrix from vectors in Matlab [solved]
I have n=1:100 three dimensional row vectors with components x(n), y(n), and z(n), representing a vector at hundred different instances of time. I would like to create a 100 row by 3 column matrix, A(n), that would contain these vectors, such that a call of, e.g., A(4) would return the vector with components x(4) y(4) z(4).
Apparently, I suck at using both Matlab and google, so my question is: How is this done in Matlab?
Edit:
My futile attempt so far looks like this:
Which of course only leaves me with H=H(100)...
Edit 2:
Adding R = [R;H]; to the line below H = ... and simply calling R(n,:) for the nth vector in question seems to do the trick, albeit not exactly the way I wanted.
I have n=1:100 three dimensional row vectors with components x(n), y(n), and z(n), representing a vector at hundred different instances of time. I would like to create a 100 row by 3 column matrix, A(n), that would contain these vectors, such that a call of, e.g., A(4) would return the vector with components x(4) y(4) z(4).
Apparently, I suck at using both Matlab and google, so my question is: How is this done in Matlab?
Edit:
My futile attempt so far looks like this:
Code:
for n = 1:100
i(n) = ...
j(n) = ...
k(n) = ...
H = [i(n), j(n), k(n)];
end;
Which of course only leaves me with H=H(100)...
Edit 2:
Adding R = [R;H]; to the line below H = ... and simply calling R(n,:) for the nth vector in question seems to do the trick, albeit not exactly the way I wanted.
Last edited by a moderator: