The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: how import a variable from script file to function file?
Replies: 3   Last Post: May 15, 2013 12:31 PM

Advanced Search

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

Posts: 118
Registered: 4/13/13
how import a variable from script file to function file?
Posted: May 15, 2013 3:21 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I have to solve a complex non-linear equation.therefore,I have two equation two unknown.
I have to solve my equation in a loop for,repeatedly(for different initial guess points).
therefore I wrote my equation in a function file and saved it.
NOW,I created a script file and I want to run this script file to run function file,for each guess point.
now my problem is that,I want to use from loop's index in function file,aslo.but I don't know how do it.
for example,my script file is:
for i =1:100
real_guess(i) = i/100;
imag_guess(i) = i/500;
my_guess = [ real_guess(i) , imag_guess(i)]
equ1 = fsolve(@my_function_name , my_guess);
I created a function as "my_function_name.m" and saved it in current directory.
Now,when call "my_function_name" in the above with fslove,I want to use from "i" index,in my_function_name program,also.
how do it?

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.