I created a function that returns [A] with a for loop inside that modifies A, an array, there is no explicit return statement. It works. I added in a 2nd nested for loop under this code and did some simple disp to show the indexes. This code ran alone just fine. But now, with the extra code added into the original function, the added code never gets run. If I put the same code before the original for loop that makes A, the code runs for both for loops. So I am guessing that once a function's return is created, the function just returns from that point in the code. That is not what I would have expected in any other language like C or C++. Why did this act so strange the first time?
function [A]=inc_array() // added in nested for loop experiment // if this code is cut and pasted below line 29, it will not execute // the function returns at line 28! // and will return even if line 29 is not there! n=3; for k=1:n-1 //1st row index disp(k,"k="); for i=k+1:n //2nd row index disp(i,"i="); for j=k:n // scan the row disp(j,"j="); end end end format("e",8); A=[1,3,5,7,9]; val = 1.5; n=size(A,2); //get the # cols, use 1 for rows for (i=1:n) //pause // to see the right side of the following statement A(i)=A(i) + val*A(i); //the debugger can olny see the left side values of a variable disp(A(i), "A(i)=") pause end A=A' endfunction