Re: cool new sytax feature in Mathematica 6, compete with Matlab?
- From: "Dana" <ddelouis@xxxxxxxxxxxxx>
- Date: Mon, 14 May 2007 19:40:59 -0400
In Mathemtica 6, now one can type
A = Table[Random[], {5}, {5}]
Hi. I like it to. :>)
Just a note about Random[] from help...(Which I like also)
"...As of Version 6.0, Random has been superseded by the functions
RandomReal and RandomInteger."
--
Dana
"Nasser Abbasi" <nma@xxxxxxxxx> wrote in message
news:uSt1i.278606$g24.98025@xxxxxxxxxxxxxxx
I just found a nice new synatx in Mathematica 6.
As any one who programmed in Matlab knows that Matlab has some nice short
cuts for working with matrices, One is the use of ':' to indicate a range
(which Fortran also has)
So, typing A(1:10) in Matlab means the elements 1 to 10.
Now in Mathematica one can do the same, but the syntax is ';;'
So, given a matrix A, say of size 5x5, and say we want to print rows 2 to
4 for columns 1 to 3 only. In Matlab we type
A=rand(5,5);
A( 2:4 , 1:3 )
In Mathemtica 6, now one can type
A = Table[Random[], {5}, {5}]
A[[ 2 ;; 4 , 1 ;; 3 ]]
isn't that cool or what?
ofcourse one can still use the Range[] to do the same
A[[ Range[2, 4], Range[1, 3] ]]
But I think ;; is better and less typing.
(What out Matlab, Mathematica is coming after you ;)
Nasser
.
- Follow-Ups:
- Re: cool new sytax feature in Mathematica 6, compete with Matlab?
- From: Gavin Scott
- Re: cool new sytax feature in Mathematica 6, compete with Matlab?
- References:
- cool new sytax feature in Mathematica 6, compete with Matlab?
- From: Nasser Abbasi
- cool new sytax feature in Mathematica 6, compete with Matlab?
- Prev by Date: elliptic integral (reloaded!)
- Next by Date: Re: Getting 3D graphs to look nice in Mathematica 6
- Previous by thread: Re: cool new sytax feature in Mathematica 6, compete with Matlab?
- Next by thread: Re: cool new sytax feature in Mathematica 6, compete with Matlab?
- Index(es):
Relevant Pages
|
|