Return a vector from a function?
|
07-06-2015, 12:55 AM
Post: #1
|
|||
|
|||
Return a vector from a function?
How can I create a user defined function to map two variables into a vector on the prime?
i.e. something along the lines of: defvect(angle, magnitude):=[magnitude*cos(angle), magnitude*sin(angle)] but that works. |
|||
07-06-2015, 07:44 AM
Post: #2
|
|||
|
|||
RE: Return a vector from a function?
OK so I solved my task by making it a program
Code:
But that really feels like tapping an exposed nail head with a sledge hammer. Is there no way to return a vector or matrix from the 'Define' window? |
|||
07-06-2015, 09:45 AM
(This post was last modified: 07-06-2015 09:46 AM by Didier Lachieze.)
Post: #3
|
|||
|
|||
RE: Return a vector from a function? | |||
07-06-2015, 10:21 AM
(This post was last modified: 07-06-2015 10:25 AM by DrD.)
Post: #4
|
|||
|
|||
RE: Return a vector from a function?
By using a list first, try this function, which will create the variables M0, mag, and ang. (Uncheck the [M0]):
[Shift] [Define] NAME: defvect Function: M0:=list2mat({mag*COS(ang), mag*SIN(ang)}) M0:[ ] mag:[ ✔] ang:[ ✔] oops, I see Didier beat me to it! |
|||
07-06-2015, 12:00 PM
Post: #5
|
|||
|
|||
RE: Return a vector from a function?
Thanks to both of you for the solution and pointing out the built in function.
|
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)