Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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 comentarios
reshdev
reshdev el 25 de Ag. de 2014
because i am generating matrix with random values in my program

Iniciar sesión para comentar.

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 25 de Ag. de 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!

Más respuestas (0)

Categorías

Más información sobre Genetic Algorithm en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by