Append an array inside a function

Chances are, especially if you have a Matlab background, that you rather want a vector than a one-column matrix, in which case this is simply

SV = rand(10)
function add_star(SV)
    for i = 1:5
        append!(SV, 4)
    end
    return SV
end

If you really want a matrix you have to go through some hoops to achieve the same thing.

4 Likes