How to push a variable in a vector in Matlab?
Something like this:
A = [5 2 3]; push(A, 7); % A = [5 2 3 7] Thanks.
I found the answer.
Use this:
A = [A, 7]; Or this:
A(end + 1) = 7; A=[A,4]; Is the most commonly used solution because it easily generalizes to more complex situations. However the first solution will also work if your vector is transposed so both have their strongpoints.A to the right of A you can simply do: A=[A,A] whilst for the first method you would need to do: A(:,end+1:end+size(A,2)) = Amy_struct.a = 10; all_structs = []; all_structs(end+1) = my_struct;