I'm facing a question about using matlab to change a given variable inside a function & return it. This function should change the value w/o create any new var
according to the description, I suppose it is something like:
vec = [1, 2, 3, 4, 5];
func(vec);
vec
1, 3, 5
after googling a lot, I've read a lot about that matlab is passing the reference rather than value. Thus the input parameter will be modified, and what I have to do is simply return it. NO luck...
Here is my code:
function x = func(x)
x = x(mod(x, 2) == 1)
end
can anyone tell me why this is not working??