Borrar filtros
Borrar filtros

Automation/Rerun the program for different inputs automatically.

1 visualización (últimos 30 días)
venkat siddhartha rama
venkat siddhartha rama el 21 de Ag. de 2019
Editada: Rik el 21 de Ag. de 2019
Hello Friends,
I am currently working on a project. In my project I have written the entire code which runs for certain value of (Example: Rows=100;Columns=100). Program calculates everything and I get the value of (Example: Price: $XYZ). I am looking for a way to automatically change the value of Rows and Columns and save corresponding value of price. I dont have to manually change the values.

Respuestas (1)

Rik
Rik el 21 de Ag. de 2019
Editada: Rik el 21 de Ag. de 2019
This is trivial if you put your code in a function:
function price=getPrice(Rows,Columns)
price=sin(Rows)*exp(Columns);%whatever
end
You can use this in a call to arrayfun to solve your initial problem:
[Rows,Columns]=ndgrid(100:50:500,100:50:500);
price=arrayfun(@getPrice,Rows,Columns);

Categorías

Más información sobre Get Started with Optimization Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by