Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: I'm new to matlab; why is this function wrong?
Replies: 5   Last Post: Dec 6, 2012 12:41 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Sargondjani

Posts: 176
Registered: 8/30/11
Re: I'm new to matlab; why is this function wrong?
Posted: Dec 6, 2012 12:41 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.