Actually there is an easier way: a =a'' Not sure how the runtime compares though..
On Tuesday, 27 October 2015 14:01:22 UTC+2, michae...@gmail.com wrote: > > Thanks. I knew there had to be an easy way. > > On Tuesday, October 27, 2015 at 12:59:43 PM UTC+1, Yichao Yu wrote: >> >> On Tue, Oct 27, 2015 at 5:47 AM, <michae...@gmail.com> wrote: >> > I have a function that expects a Matrix argument, but for the case I'm >> > working on, the natural way to construct the argument gives a vector. >> So, >> > suppose I have a vector, e.g., a=rand(10). What is the best way to >> convert >> > this to a 10X1 array? I can do it using a loop, but I thought there >> might be >> > a built-in convertor, which I fail to find. >> > Thx >> >> reshape(a, (10, 1)) if you don't mind the two to share the same >> storage and you cannot resize the first one anymore. >> >