[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
simple vector to matrix transformation
From: |
Jim Van Zandt |
Subject: |
simple vector to matrix transformation |
Date: |
Tue, 22 Jun 1999 08:38:39 -0400 |
I just needed to add the same vector to every column of a matrix.
Since octave does not automatically promote a vector to a matrix, I
did this:
a =
0.095555
0.789421
0.122409
octave:12> b=diag(a)*ones(3,4)
b =
0.095555 0.095555 0.095555 0.095555
0.789421 0.789421 0.789421 0.789421
0.122409 0.122409 0.122409 0.122409
I could then add b to the original matrix.
Of course, the multiplication is inefficient. I seem to remember
there was a more direct way to do this transformation, but I can't
find it in the docs. Is there?
- Jim Van Zandt
---------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL. To ensure
that development continues, see www.che.wisc.edu/octave/giftform.html
Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html
---------------------------------------------------------------------
- simple vector to matrix transformation,
Jim Van Zandt <=