how to run function for several times with different variables
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have something like this:
a=5
b=8
c=9
d=11
%a,b,c and d are function inputs
n=a*0.1:a*0.1:a
for i=1:length(n)
"function"
end
but I need to run function replacing 'a' in 'n' with 'b','c' and 'd' at once and save the data so I can compare it. it is a sensitivity analysis for this function outputs.
2 comentarios
dpb
el 5 de Mzo. de 2019
To do every point for all four variables would be quad-nested for loops and you'd end up with 4^10= 1048576 outputs. Depending on how expensive function() is in compute time, this might take a while...
Typically one uses response surface methods or similar to do such studies that replace the detail function with a (typically) quadratic surface over the design space. (Myers, RH, Response Surface Methodology, Allyn and Bacon, 1971 was my "go to" and still a favorite).
Respuestas (2)
Dennis
el 5 de Mzo. de 2019
In your example you do not need more than one variable:
a=[5 8 9 11];
for i=1:numel(a)
n=a(i)*0.1:a(i)*0.1:a(i);
for k=1:numel(n)
%function
end
end
2 comentarios
Asliddin Komilov
el 12 de Mzo. de 2019
Editada: Stephen23
el 12 de Mzo. de 2019
1 comentario
Stephen23
el 12 de Mzo. de 2019
You could save the bother by simply putting your data into one array and using indexing.
Ver también
Categorías
Más información sobre Genomics and Next Generation Sequencing 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!