MATLAB: How to get output in rows for running given matlab program(attached) 2 times for same inputs

genetic algorithmrandom number generator

Hello Everyone,
Please see the attached matlab program which for example,i am running for input
online1([9 1 4; 8 2 3])
suppose, I want to run this program 2 times(Say count= 2) for same inputs, then how can i get 'second time run output' below first time run output. Means my output in command window should look like—
output from first time run
output from second time run

Best Answer

reshdev - if you want to re-run your function multiple times with the same input, then just pass in a second input parameter indicating how many times you want to run the function
function online1(inputData, numRuns)
% set n based on the number of rows
n = size(inputData,1);
% do following for each run
for u=1:numRuns
% use your code from online.m
% row index into inputData
ridx = 1;
r = 6;
t = r-1;
output = zeros(r,r*n);
for ii = 1:r:r*n
% etc.
end
% now write output and run number
fprintf('output from run %d\n',u);
disp(output);
end
end
Try the above and see what happens!