# Basic function in matlab

1. Apr 3, 2009

### rem88

Hi, sorry to ask this, i know its really simple. I tried to look online for help but i couldnt understand why i was going wrong.

I have a function u = [0.25*s]/[0.005 + s]

I put this in a .m file.

I am going to use this by puting an initial value (so) in to find u. Then u is used in a differential equation to find a new s.

but when i for example write, s=2 iget this message

>> s=2

s =

2

>> u
??? Input argument "s" is undefined.

Error in ==> u at 2
u = [0.25*s]/[0.005 + s]
>>

this is my m file

function u = f(s)
u = [0.25*s]/[0.005 + s]

i havent really used mat lab before so any halp would be great.

Thanks, rem

2. Apr 3, 2009

### rem88

Sorry, just figrued it out, i have to put in u(2)

But does any one know how i know use this to put into a differentail equation (useing ODE45) to generate a new value for s. (which will b e used again in the differential)

3. Apr 3, 2009

### MATLABdude

You may want to take a look at the online documentation for how to structure arguments going into one of MATLAB's ODE solvers:
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/ode23.html

Additionally, I've posted this before in this forum, but MATLAB scripts and functions (those are the m-files you posted previously):
http://www.mathworks.com/access/helpdesk/help/techdoc/learn_matlab/f4-2525.html [Broken]

If you're just starting out with MATLAB, I highly recommend book marking the MATLAB documentation webpage... It's more comprehensive and detailed than the built-in MATLAB documentation (which is decent for on-the-fly reference). If you wanted details about, say, the 'eye' function (identity matrix generator) you would just type in

>> help eye

Last edited by a moderator: May 4, 2017
4. Apr 4, 2009

### rem88

Thanks, the links you hav posted look very helpul.

Than you