From: Ali Haider on 29 Apr 2010 07:05 I have written a function that calculates some variable "t": function t=t_from_phi(phi, far) i = 0; t = exp((phi - 2.81661)/3.648659); error = phi - phi(t, far); while (abs(error) < 1e-06) || (i > 30) i = i + 1; error = phi - phi(t, far); if(abs( error1) > 1e-06); error2 = phi - phi((t+5), far); t = t - error1 * 5/(error2 - error1); end end end the above function uses one more function "phi(t,far)" i.e. function phig = phi(t,far) phi_prod = 0.921799*log(abs(t)) + ... ((((((9.26961630e-23*t-1.1024117e-18)*t + ... 5.6284307e-15)*t-1.6093578e-11)*t + ... 2.8260446e-08)*t-3.2535245e-05)*t + ... 0.03217804 )*t+10.276527; phi_air = 3.650244*log(abs(t)) + ... ((((((1.28948870e-23*t-1.2002500e-19)*t + ... 4.1981343e-16)*t-5.7867935e-13)*t - ... 1.9034645e-10)*t+1.5470500e-06)*t - ... 1.3521020e-03)*t+2.81661; if (far == 0) phig = phi_air; else phig = (phi_air + far*phi_prod)/(1 + far); end end the values used in function 1: phi = 23 the result value of t around 287. when I tries to run the code it gives the error: ??? Subscript indices must either be real positive integers or logicals. Error in ==> t_from_phi at 5 error = phi - phi(t, far); please help me out. Check my first function! Best Regards Basharat
|
Pages: 1 Prev: Figure popunder? Next: Making A Transfer Function Denominator Variable With Time |