Within a function, addressing a generic element of a vector passed to it 
results in an external modification of the vector (i.e. argument passed by 
reference not value).


How do I obtain the same effect when using the vector operator "sum to a 
scalar" ? In short, I would like the effect of the two functions f!(z) and 
g!(z), defined below, to be the same.


function f!(z) 

for i=1:length(z) 

z[i] = 25; 

end 

z = z + 5; 

end


function g!(z) 

for i=1:length(z) 

z[i] = 30; 

end 

end


Where is my (conceptual) mistake? I would be immensely grateful for your 
help and guidance.

Reply via email to