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: 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 ]
ghasem

Posts: 72
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

Hi.
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);
...
end
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?
thanks
ghasem




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.