I wish to append my elem
to the end of an array A
.
What should I do?
I wish to append my elem
to the end of an array A
.
What should I do?
Use the following
A = [A elem] % for row array
or
A = [A; elem] % for col array
Edit: Another simpler way is (as @BenVoigt suggested) to use end
keyword
A(end+1) = elem;
which works for both row and column vectors.
Another way is
A(end+1) = elem;
which works for both row and column vectors.