Creating a Script with 2 variable inputs whilst within parameters
Mostrar comentarios más antiguos
Hello,
I have a script that is used to calculate the temperature in and out of a 3 pipe counterflow concentric heat exchanger. The parameters used require the output to be at a certain value. What I am wondering is there a way to tell the script to run with two variables varied between 1-100 (for example) and the results to be compared to a maximum value!
Thanks
5 comentarios
Andrew Cowie
el 28 de Nov. de 2017
Robert
el 28 de Nov. de 2017
please provide that script if you want hints on debugging.
Walter Roberson
el 28 de Nov. de 2017
Andrew Cowie: and are you paying professionals for solutions here? Questions here are answered by volunteers from all over the world.
Walter Roberson
el 28 de Nov. de 2017
Andrew Cowie
el 28 de Nov. de 2017
Respuestas (1)
Steven Lord
el 28 de Nov. de 2017
0 votos
You've written a script file. One of the ways script files and function files are different in MATLAB is that script files can't have input or output arguments, while function files can. It's not completely clear to me what you're looking for. Your original message suggests you're looking for ALL the parameter values that result in the temperature being below a certain value, but your last comment suggests you're looking for A set of parameter values that minimizes the temperature. Those are slightly different problems to solve. If you were to modify your script file to be a function file instead, answering either of those questions would be easier.
Evaluating your function on a grid of parameter values created by calling meshgrid and using those results with the contour function (as illustrated by the first example on that documentation page) would show you where your function takes on particular sets of values. Most likely you would want to use array operations instead of matrix operations to allow your function to operate on an array of data element-wise.
Using your function with the fmincon, fminunc, or perhaps fminsearch functions (the first two from Optimization Toolbox, the third in MATLAB) would let you search for a minimum.
1 comentario
Andrew Cowie
el 28 de Nov. de 2017
Categorías
Más información sobre Mathematics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!