On Fri, May 3, 2013 at 4:25 AM, Jeonghoon Choi <[email protected]> wrote:
> Hi, I have something to ask. I think it's very easy question.
>
> This is related to Spyder. Actually I am used to using matlab, so I am
> using spyder because it provides very similar environment to matlab.
>
> I made a scipt, 'abc.py' in which function abs(A,B,C) is defined.
>
> This function returns matrices K and S.
>
> I am now running this program by following steps.
>
> 1. type on the console as
> >>> runfile(r'abc.py')
>
> => Then I can declare the function abc(A,B,C)
>
> 2. Now, I retype (I already have the input matrices A, B and C)
> >>> (K,S) = abc(A,B,C)
>
> => Then I can get the resulting matrices, K and S.
>
> I think there would be one way to run this program by one step.
>
> If in matlab, after I made a function file, I just type >> (K,S) =
> abc(A,B,C).
>
> Please help.
>
> Thanks.
>
Hello.
In MATLAB you are generally required to place functions in their own file
and make the filename match the function name. Then you write a separate
script that calls your function. In Python, you can just place it all in
the same file and name the file whatever you'd like. In your case, call the
file test_abc.py. File contents would look like:
def abc(A,B,C):
(add the function details here)
return (K, S)
A = some matrix
B = some matrix
C = some matrix
K, S = abc(A,B,C)
print K, S
If you open this file in Spyder, you can execute it by hitting F5. You can
run it interactively like MATLAB by first hitting F6, select "Execute in
current Python or IPython interpreter", and then hit Run. Subsequent F5
hits will remember your selected preference here and will keep executing
the file in the same interrupter.
As a more general overview of Pyhton, consider the tutorial here:
http://docs.python.org/2/tutorial/index.html. It's well worth your time.
There are also several good Python sites for MATLAB users. Here's one for
example: http://mathesaurus.sourceforge.net/matlab-numpy.html.
Hope this helps.
--
You received this message because you are subscribed to the Google Groups
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/spyderlib?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.