From: Peter on
Still quite new to Matlab and learning all the amazing built in stuff.

I was computing an integral the hard way and then found the quad function so thought I would give it a try, but can't get it to work=>

function [ rho ] = rhocalc( z, tass )

rho (density) is a function of height = z, and also assumed temperature = tass.

Now I want to integrate rho (to get total optical depth) between z=50000 and 0

But I need to pass the assumed temperature profile into the function as well. My book and the matlab help don't give an example but just indicate the additional arguments can be passed in.

So I tried this:
y=quad('rhocalc',50000,0,tass)

And Matlab tells me:
==============
??? Input argument "tass" is undefined.

Error in ==> rhocalc at 15
h=R.*tass./(mr*9.81); % calculate scale height at each
temperature

Error in ==> quad at 77
y = f(x, varargin{:});
======================

Appreciate any help. Thanks.
From: Bruno Luong on
"Peter " <pgillies3(a)gmail.com> wrote in message <i3kvkj$3ob$1(a)fred.mathworks.com>...

>
> But I need to pass the assumed temperature profile into the function as well. My book and the matlab help don't give an example but just indicate the additional arguments can be passed in.

Matlab has excellent doc, you be able should navigate around and find the information, for example QUAD doc advises how to "parameterizing function" directed to the second link:

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/quad.html
http://www.mathworks.com/access/helpdesk/help/techdoc/math/bsgprpq-5.html

Bruno