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.
A = {}a = [1 2 3]; a = [A 4];Another way is
A(end+1) = elem; which works for both row and column vectors.
end is the MATLAB keyword.