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.softsys.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



ghasem
Posts:
118
Registered:
4/13/13


how import a variable from script file to function file?
Posted:
May 15, 2013 3:21 AM


Hi. I have to solve a complex nonlinear 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



