Date: Dec 6, 2012 12:41 PM
Author: Sargondjani
Subject: Re: I'm new to matlab; why is this function wrong?

It seems you are confused about the definition of inputs and outputs of functions:

a function should look like this:

function [output1,output2,...]=my_fun(input1,input2,...)

if you call this function you have to define input1, input2,... BEFORE you call the function.

When you call orbits the first time, there does not exist a Ro, so that gives an error

BUT in addition you overwrite all the input variables inside the function. you should not define Ro, Vo or del_t inside your functions if you want to take them as inputs (unless you want to transform these inputs, but i doubt that is what you want)

so you need to define initial values for Ro,Vo in the script (before the loop), and delete the values of del_t and Ro inside the function