matlab append to vector

To append an element to a vector in MATLAB, you can use the [] operator or the horzcat function. Here's an example:

% Using the [] operator
vector = [1, 2, 3];  % Original vector
element = 4;  % Element to append
vector = [vector, element];  % Appending the element to the vector

% Using the horzcat function
vector = [1, 2, 3];  % Original vector
element = 4;  % Element to append
vector = horzcat(vector, element);  % Appending the element to the vector

After executing either of these methods, the vector variable will contain the appended vector.