From: Ali Haider on
Hi:

I want to convert this function into matlab function:

double t_from_h(double h, double far)
{
unsigned char i;
double t, ht, error;
t = h/1100;
i = 0;
do
{
i++;
ht = h_gas(t, far);
error = abs(h - ht);
if (error > 1)
{
t = t + (h - ht)/cp_gas(t, far);
}
}
while ((error<1) || (i>30));
return t;
}

Please help me, how to do this.
From: Ashish Uthama on
On Mon, 15 Mar 2010 05:48:05 -0400, Ali Haider <alihaider82(a)gmail.com>
wrote:

> Hi:
>
> I want to convert this function into matlab function:
>
> double t_from_h(double h, double far)
> {
> unsigned char i;
> double t, ht, error;
> t = h/1100;
> i = 0;
> do
> {
> i++;
> ht = h_gas(t, far);
> error = abs(h - ht);
> if (error > 1)
> {
> t = t + (h - ht)/cp_gas(t, far);
> }
> }
> while ((error<1) || (i>30));
> return t;
> } Please help me, how to do this.


1.Try following the functions logic first and make sure you understand
whats going on. (for example: what is cp_gas?)

2. Familiarize yourself with basic MATLAB
Please find more details online at:
http://www.mathworks.com/access/helpdesk/help/techdoc/learn_matlab/bqr_2pl.html
Or please paste this in the MATLAB command window:
web([docroot,'/techdoc/learn_matlab/bqr_2pl.html'])

3.Look for functional equivalents. Take a guess and search the doc.
-What would you search for in the MATLAB doc to implement the abs function
call above?
-You can use the MATLAB while loop to replace do{}while in the code above.

4.Run a few tests to ensure that the logic matches