main.m146 chars11 lines
Output:
main.m9 chars3 lines
The code creates a vector x with values [16 12 14 18 13 20] and initializes myvector with zeros of size [2 1]. It then loops through each element of x using a for loop. If an element is greater than 15, it assigns that value to the corresponding index in myvector. Finally, it displays the values in myvector using the disp() function. In this case, the output is [16 0], as only the first element in x is greater than 15.
gistlibby LogSnag