To create a vector of length 9 with NaNs
from a vector of length 2, you can use the nan
function and repmat
function. Here is the code to do that:
main.m163 chars4 lines
What this code does is create a vector out
of length 9 with all elements being NaNs
using repmat
. Then, it inserts the values from the original vector v
into positions 1 and 5 using indexing notation.
The resulting vector out
will have NaN
values in all positions except the ones where the original vector was inserted:
main.m40 chars2 lines
gistlibby LogSnag