Assuming you want to add a value at the end of the vector and fill the rest of the vector with zeros, you can use the padarray function. Here's an example code:
main.m194 chars8 lines
In the code above, the padarray function pads the vector v with zeros on the right until it has the same length as the original vector minus one. The 'replicate' option tells padarray to repeat the last element of v to fill the padded elements. Finally, the last element of padded_v is set to the desired value. The resulting vector (padded_v) has the desired structure.
gistlibby LogSnag