Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'print and dimensions' topicStudent Support Forum > General > "print and dimensions"

< Previous CommentHelp | Reply To Comment | Reply To Topic
Author Comment/Response
Bill Simpson
09/07/12 1:24pm

Does this help?

In[1]:= arr=Table[0,{5}];
Do[arr[[i]]=1+0.5 i,{i,1,5}];
Print[Dimensions[arr]];
Print[arr];

From In[1]:= {5}

From In[1]:= {1.5,2.,2.5,3.,3.5}

Mathematica does not automatically create a vector, you must create that with Table[] or other ways.

Mathematica uses [] for functions so it believes arr[i] must be a function named arr with a parameter i and that is probably an error in your notebook.

Mathematica uses [[]] for vector and matrix subscripts so arr[[5]] is the fifth element in vector arr.

Mathematica uses Dimensions[] to return a list of the dimensions so {5} is a vector of lenght 5, {3,7} is a matrix of size 3 by 7, etc.

Mathematica uses Print[] to display results. If there is more than one expression in a cell in a notebook then each expression should be separated by a semicolon. If the last expression in a cell is followed by a semicolon there will be no result displayed. If the last expression in a cell is not followed by a semicolon then that result will be displayed.

URL: ,

Subject (listing for 'print and dimensions')
Author Date Posted
print and dimensions phuyer Chen 09/07/12 10:23am
Re: print and dimensions Bill Simpson 09/07/12 1:24pm
< Previous CommentHelp | Reply To Comment | Reply To Topic