Creating a Script with 2 variable inputs whilst within parameters

9 Ansichten (letzte 30 Tage)
Andrew Cowie
Andrew Cowie am 28 Nov. 2017
Kommentiert: Andrew Cowie am 28 Nov. 2017
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 Kommentare
Andrew Cowie
Andrew Cowie am 28 Nov. 2017
@Walter Roberson Using the term professional doesn't require a person to be "a professional" it relates to their attitude. I am fully aware of how a forum works, and hence why I didn't expect to get attacked for incorrectly using a "#". All I was hoping for was some help from people with more experience in MATLAB as this is my first project I have done using it.
Having now understood the process of using tags (not HASHtags) to tag articles, I understand and hope that we can all move forward from this unfortunate incident in which has obviously become a unfortunate case of mis-communication. Thanks to all who have assisted in making sure this was properly tagged.
What i was hoping to be able to do was to optimise my results by using a variety of lengths (between 0.1m and 1m) and an oil outer wall of between (45e-3m and 80e-3).
Thanks for any help,
Regards,
Andy

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Steven Lord
Steven Lord am 28 Nov. 2017
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 Kommentar
Andrew Cowie
Andrew Cowie am 28 Nov. 2017
Mr Lord,
Thank you very much for your prompt response.
Having now a greater understanding on functions and scripts, i will spend a bit of time converting it to a function file!
Thank you very much again.
(Also, it is the second option; I should of clarified in greater detail. Thanks)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by