Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Making my own mathematica functions' topicStudent Support Forum > General > "Making my own mathematica functions"

Next Comment >Help | Reply To Topic
Author Comment/Response
Alejandro
04/18/11 12:55pm

I've been using Matlab for a while, and then a friend told me about this great software....
I've been testing Mathematica for a couple of days and I wasn't able to find something:
How can I make my own function like in Matlab?

Example:

//Function Definition in a M file:

function A=Matriz(m,n)
...for i=1:m,
.......for j=1:n,
..........A(i,j)=(i*j-1);
.......end
...end


//Calling the function in the notebook:

Value1=Matriz(1,1);
Value1=[-1]

Value2=Matriz(2,3)
Value2=[x x x]
.......[x x x]

Value3=Matriz(3,5)
Value3=[x x x x x]
.......[x x x x x]
.......[x x x x x]

I'm not asking about the syntax, I'm asking about how can I define the function and then call that function, using some parameters like "m" and "n" and assign the value the function returns to a variable called Value1, Value2 and Value3.

If someone can help me with this, I will really appreciate it.


Thanks in advance and sorry for my bad English, I'm not a native English Speaker.

URL: ,

Subject (listing for 'Making my own mathematica functions')
Author Date Posted
Making my own mathematica functions Alejandro 04/18/11 12:55pm
Re: Making my own mathematica functions Carlos 04/19/11 03:06am
Re: Making my own mathematica functions Alejandro 04/28/11 6:35pm
Next Comment >Help | Reply To Topic