View Single Post
Sep7-09, 11:16 AM   #1
 

How to create a matrix from vectors in Matlab


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. Anyway, feel free to contact me for more groundbreaking problem-solving with Matlab...
 
PhysOrg.com
PhysOrg
mathematics news on PhysOrg.com

>> Mathematicians analyze social divisions using cell phone data
>> Can math models of gaming strategies be used to detect terrorism networks?
>> Mathematician proves there are infinitely many pairs of prime numbers less than 70 million units apart