I have a single row matrix theta in Matlab with a couple hundred values; I would like to create a vector for each value in theta. Preferably I can simply store these values in a list so I can take dot products of individual elements in the list lator; how would I go about doing this?
For now, the code I have is
arrayfun(@(x) [sin(x),0,cos(x)],thetas,'UniformOutput',false);
which generates a bunch of [1x3 double]‘s.
The output to your code is a cell array, whose elements are the 1×3 vectors you wanted. So suppose you assigned
A = arrayfun(@(x) [sin(x),0,cos(x)],thetas,'UniformOutput',false);as you have up there. The vector corresponding with the ith element of arraythetasmay be accessed withA{i}. At this point you could use aforloop to construct a matrix whose ith column is the vector corresponding to the ith element ofthetas.