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

1 Ansicht (letzte 30 Tage)
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
  3 Kommentare
reshdev
reshdev am 25 Aug. 2014
because i am generating matrix with random values in my program

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Geoff Hayes
Geoff Hayes am 25 Aug. 2014
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!

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by