I want to take user input entered as an integer, for example (45697), and store the first two digits in an array, vector, or something else such as ( 4 5
Since you are interested in individual digits, you don't even need to invoke str2num. One way is enough as in x_str = num2str(x);, then you subtract '0' with y = x_str(1:2)-'0';.