Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to create a matrix from vectors in Matlab

  1. Sep 7, 2009 #1
    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:
    Code (Text):

    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. Anyway, feel free to contact me for more groundbreaking problem-solving with Matlab...
     
    Last edited: Sep 7, 2009
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: How to create a matrix from vectors in Matlab
Loading...