MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: plotting multidimensional arrays


David Annetts wrote:
> Hi Mickey,
> 
> 
>>I have a list of numbers,
>>cc(1,2)=20
>>cc(1,3)=45
>>
>>and so on. I would like to plot it as a 3 dimensional plot, 
>>with the index as x and y and the value as the z value but I 
>>am having trouble doing that. Here is what I was trying. I 
>>create the array first,
>>
>>cc=Table[0,{i,500},{j,500}];
> 
> 
> You are creating an 500 x 500 array filled with zeros.
> 
> 
>>This works fine. Then I assign the values for the elements.
>>
>>cc[[1]][[2]]=20;
> 
> 
> This will return the 2nd element in the first row.  You mean cc[[1, 2]] =
> 20;
> 
> 
>>But here I get an error.
> 
> 
> Yes.  Look at Part[] in the online help.
>  
> 
>>What am I doing wrong?
> 
> 
> At the very least, assuming that you can write C(++) like code and expect it
> to work ....
> 
> You say you have a list of numbers.  Where?  On paper?  In a file on your
> disc?  Assuming it's the latter, we can read them directly into Mathematica.
> 
> 	idat  = Import["c:/Tmpfiles/Surface.dat", "CSV"];
> 	idat = ToExpression[#] & /@ idat;
> 
> And plot them as a surface (after loading the proper package)
> 
> 	Needs["Graphics`"]
> 	ListSurfacePlot3D[idat];
> 
> Or as discrete points ...
> 
> 	rdat = Partition[Flatten@idat, 3];
> 	ScatterPlot3D[rdat];
> 
> It depends on how you read your data from the file on disc, and what exactly
> you want to do with them.  
> 
> How about looking at the help for Import[] as well as ListPlot3D &
> ListSurfacePlot3D.  Try the examples.  Look at the start of the sample data
> to see the required format for the data.
> 
> Regards,
> 
> Dave.
> 

Thanks to everyone who responded. It works fine now.

-M


  • Prev by Date: Plotting with arbitary precision????
  • Next by Date: Re: Variables Within Homemade Functions
  • Previous by thread: RE: plotting multidimensional arrays
  • Next by thread: A new application for Mathematica