Message Boards Message Boards

How can I write a simple program to give several outputs for 2 inputs?

Posted 11 years ago
Hi, I am totally new to mathematica and program-writing in general. I need to write a program that calculates psychrometric properties from given inputs (dew point, humidity, etc. from pressure, dry/wet bulb temperature). I have the formulas that relate these different variables, but I've never written a program before. The program must be compatible with matlab when it is completed. If anyone could suggest how to start this or any good websites or tutorials on how to do this kind of program I would really appreciate it. Thanks a ton!
POSTED BY: Drew Hammerman
3 Replies
Posted 11 years ago
Few important notes about the implementation of the program in Mathematica:
(If I am incorrect, so please correct me)
  1.  There is a requirement for installation of Mathematica or Mathematica Player Pro or webMathematica (Mathematica included).  Each of these programs are also licensed and charged. This means that the code will be able to use only the Mathematica owner with all restrictions. Second possibility is to make a web interface on your server with your webMathematica installation (licensed too).
  2. There are no a full compiler to compile code independent of Mathematica. There are only commercial compilers with an uncertain outcome and equally dependent on the   Mathematica kernel. MATLAB has a compiler for stand alone applications but it is additional part (expensive).

If the preceding information does not mind role I would split task into several parts:
  1.  Functions with “Module” with calculation part.
  2.  Part for presentation – see: ”guide/ClickInteractivePanels”, “guide/CustomInterfaceConstruction”. It is commands for example: Panel,InputField,GraphicsGrid,Graphics,Button. Very important is command Dynamics necessary for program (variable) evaluation immediately after changing values.Button object can be used for starting evaluation (calling working Module). Very important is if you use very time constraining module or code then change default Option  Method->"Preemptive" to the  Method->"Queued" because if not your code will be aborted after some times and you will be without results.
  3. Functions for importing and exporting results from/into program. This functions are called by buttons. Nifty command is SystemDialogInput["FileOpen"].

It was general description.

More knowledgeable user might write:
Make your own Mathematica package just for your own calculation.
For export/import data use Java Form or use some link: J-Link, MathLink ....

I apologize for bad English.
Posted 11 years ago
Well just going through some of the demonstrations, I see it is quite simple to enter a function and a range of variables and use Manipulate to create an interactive app with a slider to show the outputs on a graph. I would like my final product to be similar. I have several functions to solve for variables sequentially given 3 independent variables (namely, dry and wet bulb temperatures and atmospheric pressure to give Dew point temperature, humidity, vapor pressure, enthalpy, etc.). Generally, I think it would look like this: starting variables are x, y, z. f(x) and f(y) give variables a and b to be plugged into the next equation relating all three such as g(a,b,z)=w which is humidity. w is then used in the next equation to give another output and so on. I envision a program where I can enter these values of x, y, and z and be given the outputs that follow. Function 2 of the online calculator found at is basically what I want it to do. I could probably do these calculations easily using a simple excel spreadsheet, but my instructor wants a simple user-friendly interface using Labview or Matlab. I know very little about Labview, matlab, or mathematica, but when I came along mathematica it seemed like something I could do this on and also learn to do some very powerful calculations as I became more familiar with it. Any advice in the right direction would be much appreciated! Thanks!

It looks like someone has put in something like this already in wolframalpha as well: 
POSTED BY: Drew Hammerman
Posted 11 years ago
Hi, I am beginner in Mathematica too. I would like advice for starting web:

It is difficult to answer your question because you describe your task briefly.
You can’t compare Mathlab and Mathematica because there is totally different idea of evaluation. Mathlab solving kernel is very old and it is numerical. Mathematica in general is based on rules and symbols and solution is more precise.

If you want solve your task and compare results between Mathlab and Mathematica you must standardize your Input/Output. You can use files. Your code can be this:

imp=Import[“input file”];
formula={….function of imp… , …};
Export[”export file”,formula];(*export file can be “.mat” and than is result comparable*)

It is only one choice for your solution. If you want better solution you must write additional specification.
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract